渐变画刷示例
原文:渐变画刷示例
例子代码
例子代码
<Rectangle>
<Rectangle.Fill>
<LinearGradientBrush>
<LinearGradientBrush.StartPoint>
<Point X="0" Y="0" />
</LinearGradientBrush.StartPoint>
<LinearGradientBrush.EndPoint>
<Point X="1" Y="1" />
</LinearGradientBrush.EndPoint>
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="Yellow" Offset="0.0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1.0" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
LinearGradientBrush.StartPoint:表示渐变方向的起始点,默认是坐标为0,0的点
LinearGradientBrush.EndPoint:表示渐变方向的结束点,默认是坐标为1,1的点,与StartPoint结合起来表示渐变的方向
LinearGradientBrush.GradientStops:GradientStop的集合,描述渐变中过渡点的位置和颜色
<Rectangle>
<Rectangle.Fill>
<LinearGradientBrush>
<LinearGradientBrush.StartPoint>
<Point X="0" Y="0" />
</LinearGradientBrush.StartPoint>
<LinearGradientBrush.EndPoint>
<Point X="1" Y="1" />
</LinearGradientBrush.EndPoint>
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="Yellow" Offset="0.0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1.0" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
LinearGradientBrush.StartPoint:表示渐变方向的起始点,默认是坐标为0,0的点
LinearGradientBrush.EndPoint:表示渐变方向的结束点,默认是坐标为1,1的点,与StartPoint结合起来表示渐变的方向
LinearGradientBrush.GradientStops:GradientStop的集合,描述渐变中过渡点的位置和颜色