线性渐变画刷
第一种:
1.首先先绘制一个矩形
<Button Height="60" Width="120" Margin="87 , 60 , 86.6 , 60.4" ></Button>
2.然后在Button里定义一个Background,再用一个线性渐变来写他的样式
<Button Height="60" Width="120" Margin="87,200,86.6,10.4" >
<Button.Background>
<!--线性渐变画刷-->
<LinearGradientBrush StartPoint="0 , 0.5" EndPoint="1 , 0.5" Opacity="0.5">
<GradientStop Color="Gainsboro" Offset="0"/>
<GradientStop Color="#66CCFF" Offset="0.5"/>
<GradientStop Color="DarkTurquoise" Offset="1"/>
</LinearGradientBrush>
</Button.Background>
</Button>
LinearGradientBrush是线性渐变 ;
StartPoint="0 , 0.5" EndPoint="1 , 0.5":两个点的X、Y轴,颜色会随着两个点连回来的线渐变,当你要改变渐变的方向时,只要改变那两个点就可以了。
比如: StartPoint="0 , 0" EndPoint="1 , 1"颜色是从左上到右下渐变
StartPoint="0.5 , 0" EndPoint="0.5 , 1"颜色是上下渐变
StartPoint="0 , 0.5" EndPoint="1 , 0.5"颜色是左右渐变…
GradientStop:渐变
Color="Gainsboro" Offset="0" 在0的时候颜色会是亮灰色
第二种:
1.首先先绘制一个矩形
<Button Height="60" Width="120" Margin="87 , 60 , 86.6 , 60.4" ></Button>
2. 然后在Grid里定义一个Resources,再用一个线性渐变来写他的样式
<Grid.Resources>
<LinearGradientBrush x:Key="bgBrush" StartPoint="0,0" EndPoint="1,1" Opacity="0.8">
<GradientStop Color="Red" Offset="0.0"/>
<GradientStop Color="#66CCFF" Offset="0.25"/>
<GradientStop Color="Blue" Offset="0.75"/>
<GradientStop Color="Aquamarine" Offset="1.0"/>
</LinearGradientBrush>
</Grid.Resources>
<Button x:Name="btnSubmit" Background="{StaticResource bgBrush}" Height="60" Width="120" Margin="87 , 0 , 86.6 , 167.4">
</Button>
第一种是在Button里直接定义Background,再写上样式;
第二种是调用别的地方的样式;
都是差不多的,这里只是顺便列出来而已,就不重复说了