Silverlight(9) - 2.0画笔之SolidColorBrush, ImageBrush, VideoBrush, LinearGradientBrush, RadialGradientBrush
2008-11-14 11:50:38 来源:WEB开发网4、LinearGradientBrush.xaml
<UserControl x:Class="Silverlight20.Brush.LinearGradientBrush"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel HorizontalAlignment="Left">
<Grid Margin="10">
<Rectangle Width="200" Height="100" HorizontalAlignment="Left">
<Rectangle.Fill>
<!--LinearGradientBrush - 线性渐变画笔-->
<!--
StartPoint - 线性渐变的起点。默认渐变方向为对角线方向,默认值为左上角0,0
EndPoint - 线性渐变的终点。默认渐变方向为对角线方向,默认值为右下角1,1
GradientStop - 渐变中,过渡点的设置
GradientStop.Color - 过渡点的颜色
GradientStop.Offset - 过渡点的位置。相对于渐变线的比值。最小值0.0(默认值),最大值1.0
ColorInterpolationMode - 插入渐变颜色的方式 [System.Windows.Media.ColorInterpolationMode枚举]
ColorInterpolationMode.ScRgbLinearInterpolation - scRGB
ColorInterpolationMode.SRgbLinearInterpolation - sRGB。默认值
-->
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1" ColorInterpolationMode="SRgbLinearInterpolation">
<GradientStop Color="Red" Offset="0.0" />
<GradientStop Color="Green" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="Yellow" Offset="1.0" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Line X1="0" Y1="0" X2="200" Y2="100" Stroke="Black" HorizontalAlignment="Left" />
</Grid>
<Grid Margin="10">
<Rectangle Width="200" Height="100" HorizontalAlignment="Left">
<Rectangle.Fill>
<!--
MappingMode - 指定线性渐变的起点(StartPoint)和终点(EndPoint)相对于输出区域是相对的还是绝对的 [System.Windows.Media.BrushMappingMode枚举]
MappingMode.RelativeToBoundingBox - 相对坐标。默认值
MappingMode.Absolute - 绝对坐标
-->
<LinearGradientBrush StartPoint="0,0" EndPoint="200,100" MappingMode="Absolute">
<GradientStop Color="Red" Offset="0.0" />
<GradientStop Color="Green" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="Yellow" Offset="1.0" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Line X1="0" Y1="0" X2="200" Y2="100" Stroke="Black" HorizontalAlignment="Left" />
</Grid>
<Grid Margin="10">
<Rectangle Width="200" Height="100" HorizontalAlignment="Left">
<Rectangle.Fill>
<!--
SpreadMethod - 线性渐变线(黑色线)之外, 输出区域之内的渐变方式 [System.Windows.Media.GradientSpreadMethod枚举]
GradientSpreadMethod.Pad - 用线性渐变线末端的颜色值填充剩余空间。默认值
-->
<LinearGradientBrush StartPoint="0.4,0.5" EndPoint="0.6,0.5" SpreadMethod="Pad">
<GradientStop Color="Red" Offset="0.0" />
<GradientStop Color="Green" Offset="1.0" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Line X1="80" Y1="50" X2="120" Y2="50" Stroke="Black" HorizontalAlignment="Left" />
</Grid>
<Grid Margin="10">
<Rectangle Width="200" Height="100" HorizontalAlignment="Left">
<Rectangle.Fill>
<!--
SpreadMethod - 线性渐变线(黑色线)之外, 输出区域之内的渐变方式 [System.Windows.Media.GradientSpreadMethod枚举]
GradientSpreadMethod.Reflect - 相邻填充区域,以 相反方向 重复渐变,直至填充满整个剩余空间
-->
<LinearGradientBrush StartPoint="0.4,0.5" EndPoint="0.6,0.5" SpreadMethod="Reflect">
<GradientStop Color="Red" Offset="0.0" />
<GradientStop Color="Green" Offset="1.0" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Line X1="80" Y1="50" X2="120" Y2="50" Stroke="Black" HorizontalAlignment="Left" />
</Grid>
<Grid Margin="10">
<Rectangle Width="200" Height="100" HorizontalAlignment="Left">
<Rectangle.Fill>
<!--
SpreadMethod - 线性渐变线(黑色线)之外, 输出区域之内的渐变方式 [System.Windows.Media.GradientSpreadMethod枚举]
GradientSpreadMethod.Repeat - 相邻填充区域,以 相同方向 重复渐变,直至填充满整个剩余空间
-->
<LinearGradientBrush StartPoint="0.4,0.5" EndPoint="0.6,0.5" SpreadMethod="Repeat">
<GradientStop Color="Red" Offset="0.0" />
<GradientStop Color="Green" Offset="1.0" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Line X1="80" Y1="50" X2="120" Y2="50" Stroke="Black" HorizontalAlignment="Left" />
</Grid>
</StackPanel>
</UserControl>
Tags:Silverlight 画笔 SolidColorBrush
编辑录入:爽爽 [复制链接] [打 印]- ››silverlight全屏显示图片
- ››Silverlight MVVM 模式(一) 切近实战
- ››Silverlight for Windows Phone 7开发系列(1):...
- ››Silverlight for Windows Phone 7开发系列(2):...
- ››Silverlight for Windows Phone 7开发系列(3):...
- ››Silverlight for Windows Phone 7开发系列(4):...
- ››Silverlight for Symbian
- ››Silverlight3系列(四)数据绑定 Data Binding 1
- ››silverlight2 游戏 1 你能坚持多少秒
- ››Silverlight开发实践--PicZoomShow
- ››Silverlight自定义控件开发 - 令人懊恼的OnApplyT...
- ››Silverlight 2 RTW中ToolTipService.ToolTip不继承...
- 中查找“Silverlight(9) - 2.0画笔之SolidColorBrush, ImageBrush, VideoBrush, LinearGradientBrush, RadialGradientBrush”更多相关内容
- 中查找“Silverlight(9) - 2.0画笔之SolidColorBrush, ImageBrush, VideoBrush, LinearGradientBrush, RadialGradientBrush”更多相关内容
- 上一篇:Silverlight(10) - 2.0其它之Transform详解,以及UIElement和FrameworkElement的常用属性
- 下一篇:Silverlight(8) - 2.0图形之基类System.Windows.Shapes.Shape
更多精彩
赞助商链接