WPF几种渐变色

 

[LinearGradientBrush-- 主要属性:

StartPoint 获取或设置线性渐变的二维起始坐标。

EndPoint 获取或设置线性渐变的二维终止坐标。

例子:

<LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="Blue" Offset="0"></GradientStop> <GradientStop Color="Red" Offset="0.3"></GradientStop> <GradientStop Color="White" Offset="1"></GradientStop> </LinearGradientBrush>

[GradientStop-主要属性:

Color 获取或设置渐变停止点的颜色。

Offset 获取渐变停止点在渐变向量中的位置。(一般设置可见区域 0-1)

例子:

<RadialGradientBrush GradientOrigin="0.7,0.3" RadiusX="1" RadiusY="1"> <GradientStop Color="White" Offset="0"></GradientStop> <GradientStop Color="Blue" Offset="1"></GradientStop> </RadialGradientBrush>

径向渐变:

 <StackPanel> <Rectangle  Margin="5" Width="150" Height="100"> <Rectangle.Fill> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="Blue" Offset="0"></GradientStop> <GradientStop Color="Red" Offset="0.3"></GradientStop> <GradientStop Color="White" Offset="1"></GradientStop> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <TextBlock Margin="5" Text="This text uses a gradient" Height="23" Name="textBlock1"> <TextBlock.Foreground> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <GradientStop Color="Blue" Offset="0"></GradientStop> <GradientStop Color="Red" Offset="0.3"></GradientStop> <GradientStop Color="White" Offset="1"></GradientStop> </LinearGradientBrush> </TextBlock.Foreground> </TextBlock> <Ellipse Height="150" Name="ellipse" Stroke="Black" Margin="228,0,132,0"> <Ellipse.Fill> <RadialGradientBrush GradientOrigin="0.7,0.3" RadiusX="1" RadiusY="1"> <GradientStop Color="White" Offset="0"></GradientStop> <GradientStop Color="Blue" Offset="1"></GradientStop> </RadialGradientBrush> </Ellipse.Fill> </Ellipse> </StackPanel>

 

posted @ 2018-12-06 10:44  绳命如此井猜  阅读(1573)  评论(0编辑  收藏  举报