Grid的网格布局控件,使用网格布局时候需要先确定行数列数。
Grid.RowDefinitions 设置行
<Grid><Grid.RowDefinitions><RowDefinition Height="45"/><RowDefinition /><RowDefinition Height="20"/></Grid.RowDefinitions></Grid>
Grid.ColumnDefinitions 设置列
<Grid><Grid.ColumnDefinitions><ColumnDefinition Width="60" /><ColumnDefinition Width="AUTO" /><ColumnDefinition /></Grid.ColumnDefinitions></Grid>
RadialgradientBrush(圆形梯度画刷)
只需要设定圆心坐标和X坐标和Y坐标的值就可以画一个圆形渐变,在wpf中同样需要这三个元素,
分别对应设Center,RadiusX,RadiusY,当然在wpf中还存在一个“梯度原点“:GradientOrigin。
渐变的选项有:RadialGradientBrush、LinearGradientBrush。
GradientStop 渐变 ,设置渐变色
<Grid><Grid.Background><RadialGradientBrush><GradientStop Color="#FF285173" Offset="0" /><GradientStop Color="#FF244967" Offset="0.3" /><GradientStop Color="#FF14273A" Offset="1" /></RadialGradientBrush></Grid.Background><Grid.RowDefinitions><RowDefinition Height="45"/><RowDefinition /><RowDefinition Height="20"/></Grid.RowDefinitions></Grid>
跨行 Grid.RowSpan="2" 这里是跨2行
跨列 Grid.ColumnSpan="2" 这里是跨2列
<StackPanel Grid.ColumnSpan="2" Grid.Row="10" VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Horizontal" Margin="60,0,0,0"><!-- {Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window}},找类型为window类型的父级对象 --><Button Content="保存" Width="80" Command="{Binding SaveCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window}}"/><Button Content="取消" Width="80" Margin="40,0,0,0" Command="{Binding CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window}}" />
</StackPanel>