线性渐变画刷

第一种:

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,再写上样式;

第二种是调用别的地方的样式;

都是差不多的,这里只是顺便列出来而已,就不重复说了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值