..
http://www.vr-online.ru/blog/osvaivaem-wpf-vmeste-chast3-ispolzuem-resursy-i-kisti-brushes-6778
:
4. WPF.
: WPF.
: WPF VS 2013 C#.
: 4 .
. WPF
Xaml, . , 1 . ( Xaml ). , , , , Xaml.
, WPF ? ( , ).
, : "" . ? , WPF, , . , , , .
WPF .
: , !!!
. , . , , . , , Grid, , , Xaml :
<Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions>, , , , RowDefinitions Height, Height *, , . , .1.
1. Grid (Height="*").
, Xaml Visual Studio .
, : (, ) , , . , , Height RowDefinitions auto.
. StackPanel. , . , , , . , Orientation Horizontal.
, Xaml :
|
|
, auto, , , . .2. .
2. .
, Border . . , , Add-New folder (.3.)
3. .
Border , : , , CornerRadius.
<Border BorderBrush="#FFCBBEBE" BorderThickness="2" CornerRadius="10" > <StackPanel Orientation="Horizontal" Margin="4" > <Button ToolTip="" Margin="4" Background="White" BorderBrush="Transparent" > <Image Source="Icons\open.png" ></Image> </Button> <Button ToolTip="" Margin="4" Background="White" BorderBrush="Transparent" > <Image Source="Icons\copy.png" ></Image> </Button> <Button Margin="4" ToolTip="" Background="White" BorderBrush="Transparent" > <Image Source="Icons\clear.png" ></Image> </Button> <Button Margin="4" ToolTip="" Background="White" BorderBrush="Transparent" > <Image Source="Icons\paste.png" ></Image> </Button> </StackPanel> </Border>
, Border StackPanel , . CornerRadius 10. , : 10,0,20,10. (10), (0), (20), (10). Bordera . BorderThickness Bordera , BorderBrush .
, Image, Source . WPF , ( , , TextBox, - ) .
, , Margin, , , Margin , .
.4.
|
|
Ads by Radio CanyonAd Options
4. .
, , . : , , .
Border, . , . Grid , DockPanel , . Border Bordera . Xaml :
.5. .
5. .
, DockPanel , . , , DockPanel, , . DockPanel.
. C#, , WPF , .
(Brushes)
WPF- ., , , WPF , . , / .
, WPF . .
, . .
, , . .1. , .
1. .
, , , . Background, , , .
Xaml , Background StackPanel , :
|
|
<Border BorderBrush="#FFCBBEBE" BorderThickness="2" CornerRadius="10,0,15,20" >
<StackPanel Orientation="Horizontal" Margin="4" >
<StackPanel.Background>
<LinearGradientBrush>
<GradientStop Color="AliceBlue" Offset="0.0" />
<GradientStop Color="Aqua" Offset="0.5" />
<GradientStop Color="Aquamarine" Offset="0.6" ></GradientStop>
<GradientStop Color="BlanchedAlmond" Offset="0.7" ></GradientStop>
<GradientStop Color="Chartreuse" Offset="0.9" ></GradientStop>
<GradientStop Color="Gainsboro" Offset="1.0" ></GradientStop>
</LinearGradientBrush>
</StackPanel.Background>
<Button ToolTip="" Margin="4" Background="White" BorderBrush="Transparent" >
<Image Source="Icons\open.png" ></Image>
</Button>
, StackPanel.Background .
, LinearGradientBrush, , . , . , GradientStop. , GradientStop 6 , 6 , . Offset , . Offset 0.0 1.1. , AliceBlue 0.0, . Aqua, 0.5. Offset. .2.
2. LinearGradientBrush.
, Background , . , , WPF , .
(Brushes), LinearGradientBrish , , , SolidColorBrush ( ), RadialColorBrush ( , ), ImageBrush . DrawingBrush, VisualBrush. , , . , , , .
, , . : Xaml Grida.
<Border Background="Beige" BorderBrush="#FFCBBEBE" Grid.Row="1" BorderThickness="2" CornerRadius="5,5,0,0" >
|
|
<Grid Margin="5" >
<Grid.Background>
<LinearGradientBrush>
<GradientStop Color="AliceBlue" Offset="0.0" />
<GradientStop Color="Aqua" Offset="0.5" />
<GradientStop Color="Aquamarine" Offset="0.6" ></GradientStop>
<GradientStop Color="BlanchedAlmond" Offset="0.7" ></GradientStop>
<GradientStop Color="Chartreuse" Offset="0.9" ></GradientStop>
<GradientStop Color="Gainsboro" Offset="1.0" ></GradientStop>
</LinearGradientBrush>
</Grid.Background>
, , Grid.Background .
.3.
3. LinearGradientBrush Grid'a.
, , , . , , . , WPF (Resources). Resources, . , . , , . , , .
:
<Window x:Class="WPF2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" WindowStartupLocation="CenterScreen" >
<Window.Resources>
<LinearGradientBrush x:Key="linearPanelBrush" >
<GradientStop Color="AliceBlue" Offset="0.0" />
<GradientStop Color="Aqua" Offset="0.5" />
<GradientStop Color="Aquamarine" Offset="0.6" ></GradientStop>
<GradientStop Color="BlanchedAlmond" Offset="0.7" ></GradientStop>
<GradientStop Color="Chartreuse" Offset="0.9" ></GradientStop>
<GradientStop Color="Gainsboro" Offset="1.0" ></GradientStop>
</LinearGradientBrush>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
, , x:key . StackPanel Gride, BackGrounda , Background . :
<Border BorderBrush="#FFCBBEBE" BorderThickness="2" CornerRadius="10,0,15,20" >
<StackPanel Orientation="Horizontal" Margin="4" Background="{StaticResource linearPanelBrush}" >
..
Grida:
<Grid Margin="5" Background="{StaticResource linearPanelBrush}" >
<Grid.RowDefinitions>
Background . , , ( ..) . StaticResource, . (StaticResource) (DynamicResource). , . , , Background LinearGradientBrush.
WPF , . (Brushes), LinearGradientBrush.