
[源码下载]
稳扎稳打Silverlight(8) - 2.0图形之基类System.windows.Shapes.Shape
作者: webabcd
介绍
Silverlight 2.0 图形:基类System.windows.Shapes.Shape(Ellipse,line,Path,polygon,polyline,Rectangle都继承自抽象类System.windows.Shapes.Shape)。
Fill - 填充(System.windows.Media.Brush类型)
stroke - 笔触(System.windows.Media.Brush类型)
strokeThickness - 笔触尺寸
Stretch - 拉伸值 [System.windows.Media.Stretch 枚举]
strokeDashArray - 虚线和间隙的值的集合 [System.windows.Media.Stretch 枚举]
strokeDashCap - 虚线两端(线帽)的类型 [System.windows.Media.PenlineCap 枚举]
strokeStartlineCap - 虚线起始端(线帽)的类型 [System.windows.Media.PenlineCap 枚举]
strokeEndlineCap - 虚线终结端(线帽)的类型 [System.windows.Media.PenlineCap 枚举]
strokeDashOffset - 虚线的起始位置。从虚线的起始端的 strokeDashOffset 距离处开始描绘虚线
strokelineJoin - 图形连接点处的连接类型 [System.windows.Media.PenlineJoin 枚举]
strokeMiterlimit - 斜接长度 与 strokeThickness/2 的比值。默认值 10,最小值 1
在线DEMO
http://www.cnblogs.com/webabcd/archive/2008/10/09/1307486.html
示例
Shape.xaml
< UserControl x:Class ="Silverlight20.Shape.Shape"
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml" >
< StackPanel HorizontalAlignment ="left" >
< GrID margin ="10" HorizontalAlignment ="left" >
<!--
Fill - 填充(System.windows.Media.Brush类型)
stroke - 笔划(边框)(System.windows.Media.Brush类型)
strokeThickness - 笔划(边框)尺寸
-->
< Rectangle WIDth ="200" Height ="50" Fill ="Red" stroke ="Yellow" strokeThickness ="3" />
</ GrID >
< GrID WIDth ="200" Height ="200" margin ="10" HorizontalAlignment ="left" ShowGrIDlines ="True" >
< GrID.RowDeFinitions >
< RowDeFinition Height ="100" />
< RowDeFinition Height ="100" />
</ GrID.RowDeFinitions >
< GrID.ColumnDeFinitions >
< ColumnDeFinition WIDth ="100" />
< ColumnDeFinition WIDth ="100" />
</ GrID.ColumnDeFinitions >
<!-- Stretch属性 - 拉伸值 [System.windows.Media.Stretch 枚举] -->
<!--
Stretch.None - 不做处理
不做任何拉伸处理,填充内容保持原始大小
-->
< Rectangle GrID.Row ="0" GrID.Column ="0"
WIDth ="80" Height ="40" Fill ="Red" stroke ="Yellow" strokeThickness ="6"
Stretch ="None" />
<!--
Stretch.Fill - 充满
调整填充内容,以充满整个容器,填充内容比例变为容器比例。默认值
-->
< Rectangle GrID.Row ="0" GrID.Column ="1"
WIDth ="180" Height ="40" Fill ="Red" stroke ="Yellow" strokeThickness ="6"
Stretch ="Fill" />
<!--
Stretch.Uniform - 等比适应
调整填充内容,以适合容器尺寸,填充内容会做等比例调整
如果填充内容与容器比例不一样,那么填充内容调整的结果为:
使得填充内容的宽与容器的宽相等,或者 填充内容的高与容器的高相等。填充内容会被完整显示
-->
< Rectangle GrID.Row ="1" GrID.Column ="0"
WIDth ="80" Height ="40" Fill ="Red" stroke ="Yellow" strokeThickness ="6"
Stretch ="Uniform" />
<!--
Stretch.UniformToFill - 等比充满
调整填充内容,以适合容器尺寸,填充内容会做等比例调整
如果填充内容与容器比例不一样,那么填充内容调整的结果为:
使得填充内容的宽与容器的宽相等,并且 填充内容的高与容器的高相等。填充内容会被做相应的剪裁
-->
< Rectangle GrID.Row ="1" GrID.Column ="1"
WIDth ="80" Height ="40" Fill ="Red" stroke ="Yellow" strokeThickness ="6"
Stretch ="UniformToFill" />
</ GrID >
< GrID margin ="10" HorizontalAlignment ="left" >
< GrID.RowDeFinitions >
< RowDeFinition Height ="20" />
< RowDeFinition Height ="20" />
< RowDeFinition Height ="20" />
< RowDeFinition Height ="20" />
< RowDeFinition Height ="20" />
< RowDeFinition Height ="20" />
< RowDeFinition Height ="20" />
</ GrID.RowDeFinitions >
<!--
strokeDashArray - 虚线和间隙的值的集合 [System.windows.Media.Stretch 枚举]
奇数项为虚线长度;偶数项为间隙长度;如果只有一个值,则虚线长度和间隙长度都为该值
-->
< line GrID.Row ="0" X1 ="0" Y1 ="0" X2 ="400" Y2 ="0" stroke ="Red" strokeThickness ="10"
strokeDashArray ="2" />
<!--
strokeDashCap - 虚线两端(线帽)的类型 [System.windows.Media.PenlineCap 枚举]
PenlineCap.Flat - 无。默认值
PenlineCap.Round - 直径等于 strokeThickness
PenlineCap.Square - 高度等于 strokeThickness 并且 宽度等于 strokeThickness/2
PenlineCap.Triangle - 底边长等于 strokeThickness 的等腰直角三角形
-->
< line GrID.Row ="1" X1 ="0" Y1 ="0" X2 ="400" Y2 ="0" stroke ="Red" strokeThickness ="10"
strokeDashArray ="2,4,6" strokeDashCap ="Flat" />
< line GrID.Row ="2" X1 ="0" Y1 ="0" X2 ="400" Y2 ="0" stroke ="Red" strokeThickness ="10"
strokeDashArray ="2,6" strokeDashCap ="Round" />
< line GrID.Row ="2" X1 ="0" Y1 ="0" X2 ="400" Y2 ="0" stroke ="Black" strokeThickness ="10"
strokeDashArray ="2,6" strokeDashCap ="Flat" />
< line GrID.Row ="3" X1 ="0" Y1 ="0" X2 ="400" Y2 ="0" stroke ="Red" strokeThickness ="10"
strokeDashArray ="2,6" strokeDashCap ="Square" />
< line GrID.Row ="3" X1 ="0" Y1 ="0" X2 ="400" Y2 ="0" stroke ="Black" strokeThickness ="10"
strokeDashArray ="2,6" strokeDashCap ="Flat" />
< line GrID.Row ="4" X1 ="0" Y1 ="0" X2 ="400" Y2 ="0" stroke ="Red" strokeThickness ="10"
strokeDashArray ="2,6" strokeDashCap ="Triangle" />
< line GrID.Row ="4" X1 ="0" Y1 ="0" X2 ="400" Y2 ="0" stroke ="Black" strokeThickness ="10"
strokeDashArray ="2,6" strokeDashCap ="Flat" />
<!--
strokeStartlineCap - 虚线起始端(线帽)的类型 [System.windows.Media.PenlineCap 枚举]
strokeEndlineCap - 虚线终结端(线帽)的类型 [System.windows.Media.PenlineCap 枚举]
-->
< line GrID.Row ="5" X1 ="0" Y1 ="0" X2 ="400" Y2 ="0" stroke ="Red" strokeThickness ="10"
strokeDashArray ="2,6" strokeStartlineCap ="Square" strokeEndlineCap ="Triangle" />
< line GrID.Row ="5" X1 ="0" Y1 ="0" X2 ="400" Y2 ="0" stroke ="Black" strokeThickness ="10"
strokeDashArray ="2,6" strokeDashCap ="Flat" />
<!--
strokeDashOffset - 虚线的起始位置。从虚线的起始端的 strokeDashOffset 距离处开始描绘虚线
-->
< line GrID.Row ="6" X1 ="0" Y1 ="0" X2 ="400" Y2 ="0" stroke ="Red" strokeThickness ="10"
strokeDashArray ="2,6" strokeDashOffset ="1" />
</ GrID >
< GrID margin ="10" HorizontalAlignment ="left" ShowGrIDlines ="True" >
< GrID.ColumnDeFinitions >
< ColumnDeFinition WIDth ="120" />
< ColumnDeFinition WIDth ="120" />
< ColumnDeFinition WIDth ="120" />
</ GrID.ColumnDeFinitions >
<!-- strokelineJoin属性 - 图形连接点处的连接类型 [System.windows.Media.PenlineJoin 枚举] -->
<!--
strokelineJoin.Bevel - 线形连接
-->
< polyline GrID.Column ="0"
Points ="10,100 50,10 100,100" stroke ="Red" strokeThickness ="20" HorizontalAlignment ="Center"
strokelineJoin ="Bevel" />
<!--
strokelineJoin.Miter - 角形连接。默认值
-->
< polyline GrID.Column ="1"
Points ="10,100" stroke ="Red" strokeThickness ="20" HorizontalAlignment ="Center"
strokelineJoin ="Miter" />
<!--
strokelineJoin.Round - 弧形连接
-->
< polyline GrID.Column ="2"
Points ="10,100" stroke ="Red" strokeThickness ="20" HorizontalAlignment ="Center"
strokelineJoin ="Round" />
</ GrID >
< GrID margin ="10" HorizontalAlignment ="left" ShowGrIDlines ="True" >
< GrID.ColumnDeFinitions >
< ColumnDeFinition WIDth ="120" />
< ColumnDeFinition WIDth ="120" />
< ColumnDeFinition WIDth ="120" />
</ GrID.ColumnDeFinitions >
<!-- strokeMiterlimit属性 - 斜接长度(蓝色线部分)与 strokeThickness/2 的比值。默认值 10,最小值 1 -->
< polyline GrID.Column ="0"
Points ="0,100" stroke ="Red" strokeThickness ="20"
strokeMiterlimit ="1" />
< line GrID.Column ="0" X1 ="0" Y1 ="100" X2 ="50" Y2 ="10" stroke ="Yellow" />
< line GrID.Column ="0" X1 ="50" Y1 ="10" X2 ="100" Y2 ="100" stroke ="Yellow" />
< line GrID.Column ="0" X1 ="50" Y1 ="10" X2 ="50" Y2 ="0" stroke ="Blue" />
< polyline GrID.Column ="1"
Points ="0,100" stroke ="Red" strokeThickness ="20"
strokeMiterlimit ="2.0" />
< line GrID.Column ="1" X1 ="0" Y1 ="100" X2 ="50" Y2 ="10" stroke ="Yellow" />
< line GrID.Column ="1" X1 ="50" Y1 ="10" X2 ="100" Y2 ="100" stroke ="Yellow" />
< line GrID.Column ="1" X1 ="50" Y1 ="10" X2 ="50" Y2 ="-10" stroke ="Blue" />
< polyline GrID.Column ="2"
Points ="0,100" stroke ="Red" strokeThickness ="20"
/>
< line GrID.Column ="2" X1 ="0" Y1 ="100" X2 ="50" Y2 ="10" stroke ="Yellow" />
< line GrID.Column ="2" X1 ="50" Y1 ="10" X2 ="100" Y2 ="100" stroke ="Yellow" />
< line GrID.Column ="2" X1 ="50" Y1 ="10" X2 ="50" Y2 ="-10" stroke ="Blue" />
</ GrID >
</ StackPanel >
</ UserControl >
OK
[源码下载] 总结
以上是内存溢出为你收集整理的稳扎稳打Silverlight(8) - 2.0图形之基类System.Windows.Shapes.Shape全部内容,希望文章能够帮你解决稳扎稳打Silverlight(8) - 2.0图形之基类System.Windows.Shapes.Shape所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)