学Silverlight 2系列(27):使用Brush进行填充
2008-10-03 11:38:33 来源:WEB开发网下面我们对渐变的坐标以及各个颜色渐变的偏移量做一下解释,如下图所示:
设置不同的渐变起始点和偏移量我们可以得到多种不同的渐变效果,如下面的示例:
<Canvas Background="#FFFFFF">
<Rectangle Canvas.Top="80" Canvas.Left="20"
Width="120" Height="80" Stroke="Green"
StrokeThickness="4">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="#FBFE03" Offset="0.0" />
<GradientStop Color="#41F702" Offset="0.25" />
<GradientStop Color="#FF0000" Offset="0.75" />
<GradientStop Color="#0066FF" Offset="1.0" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Canvas.Top="80" Canvas.Left="160"
Width="120" Height="80" Stroke="Green"
StrokeThickness="4">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FBFE03" Offset="0.0" />
<GradientStop Color="#41F702" Offset="0.25" />
<GradientStop Color="#FF0000" Offset="0.75" />
<GradientStop Color="#0066FF" Offset="1.0" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Canvas.Top="80" Canvas.Left="300"
Width="120" Height="80" Stroke="Green"
StrokeThickness="4">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="#FBFE03" Offset="0.0" />
<GradientStop Color="#41F702" Offset="0.25" />
<GradientStop Color="#FF0000" Offset="0.75" />
<GradientStop Color="#0066FF" Offset="1.0" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Canvas>
运行后如下图所示:
Tags:Silverlight 系列 使用
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接