原文:WPF,SilverLight中直线的样式示例

XAML代码:
// LineStyle.xaml
<Viewbox Width="600" Height="500"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Canvas Width="600" Height="500">
        <Canvas.Resources>
            <DrawingBrush x:Key="MyGridBrushResource1" Viewport="0,0,100,100" ViewportUnits="Absolute" TileMode="Tile">
                <DrawingBrush.Drawing>
                    <DrawingGroup>
                        <DrawingGroup.Children>
                            <!--横线-->
                            <GeometryDrawing Geometry="M0,1 L10,1 M0,2 L10,2 M0,3 L10,3 M0,4 L10,4 M0,5 L10,5 M0,6 L10,6 M0,7 L10,7 M0,8 L10,8 M0,9 L10,9">
                                <GeometryDrawing.Pen>
                                    <Pen Thickness="0.1" Brush="#CCCCFF" />
                                </GeometryDrawing.Pen>
                            </GeometryDrawing>
                            <!--竖线-->
                            <GeometryDrawing Geometry="M1,0 L1,10 M2,0 L2,10 M3,0 L3,10 M4,0 L4,10 M5,0 L5,10 M6,0 L6,10 M7,0 L7,10 M8,0 L8,10 M9,0 L9,10">
                                <GeometryDrawing.Pen>
                                    <Pen Thickness="0.1" Brush="#CCCCFF" />
                                </GeometryDrawing.Pen>
                            </GeometryDrawing>
                            <!-- 这里是横线 -->
                            <GeometryDrawing Geometry="M0,0 L10,0">
                                <GeometryDrawing.Pen>
                                    <Pen Thickness="0.1" Brush="DarkOrange" />
                                </GeometryDrawing.Pen>
                            </GeometryDrawing>
                            <!-- 这里是竖线 -->
                            <GeometryDrawing Geometry="M0,0 L0,10">
                                <GeometryDrawing.Pen>
                                    <Pen Thickness="0.1" Brush="DarkOrange" />
                                </GeometryDrawing.Pen>
                            </GeometryDrawing>
                        </DrawingGroup.Children>
                    </DrawingGroup>
                </DrawingBrush.Drawing>
            </DrawingBrush>

            <!-- 这里是外框线 -->
            <Style x:Key="MyGridBorderStyle">
                <Setter Property="Border.Background" Value="{StaticResource MyGridBrushResource1}"/>
                <Setter Property="Border.HorizontalAlignment" Value="Center"/>
                <Setter Property="Border.VerticalAlignment" Value="Top"/>
                <Setter Property="Border.BorderBrush" Value="Black"/>
                <Setter Property="Border.BorderThickness" Value="1"/>
            </Style>
        </Canvas.Resources>

        <Border Style="{StaticResource MyGridBorderStyle}">
            <Canvas Width="630" Height="400">
                <Line Stroke="Black" X1="0" Y1="20" X2="400" Y2="20" StrokeDashArray="1,1" StrokeThickness="30"/>
                <Line Stroke="Black" X1="0" Y1="60" X2="400" Y2="60" StrokeDashArray="1,1,2" StrokeThickness="30" />
                <Line Stroke="Black" X1="0" Y1="100" X2="400" Y2="100" StrokeDashArray="1,1,2,2"
   StrokeThickness="30"  StrokeDashCap="Round" StrokeStartLineCap="Round"  StrokeEndLineCap="Round" />
                <Line Stroke="Black" X1="0" Y1="140" X2="400" Y2="140" StrokeDashArray="1,1,2,2" StrokeThickness="30"
   StrokeStartLineCap="Round"  StrokeEndLineCap="Round" />

                <Line Stroke="Black" X1="0" Y1="180" X2="400" Y2="180" StrokeDashArray="0,1"
   StrokeThickness="30" StrokeDashCap="Round" StrokeStartLineCap="Round"  StrokeEndLineCap="Round" />

                <Line Stroke="Black" X1="0" Y1="220" X2="400" Y2="220" StrokeDashArray="0,2" StrokeThickness="30"
   StrokeDashCap="Round" StrokeStartLineCap="Round"  StrokeEndLineCap="Round" />

                <Line Stroke="Black" X1="0" Y1="260" X2="400" Y2="260" StrokeDashArray="0,2,0,2" StrokeThickness="30"
   StrokeDashCap="Round" StrokeStartLineCap="Round"  StrokeEndLineCap="Round" />

                <Line Stroke="Black" X1="0" Y1="300" X2="400" Y2="300" StrokeDashArray="0,1,1" StrokeThickness="30"
   StrokeDashCap="Round" StrokeStartLineCap="Round"  StrokeEndLineCap="Round" />

                <Line Stroke="Black" X1="0" Y1="340" X2="400" Y2="340" StrokeDashArray="0,2,1,0" StrokeThickness="30"
   StrokeDashCap="Round" StrokeStartLineCap="Round"  StrokeEndLineCap="Round" />

            </Canvas>
        </Border>
    </Canvas>
</Viewbox>

运行效果:

最新文章

  1. Android 手机卫士--构建服务端json、请求网络数据
  2. 【转】Linux IO实时监控iostat命令详解
  3. [转]B树、B-树、B+树、B*树
  4. Python-内置类属性
  5. HTML5 IE兼容问题
  6. PHP不到100行代码实现SSO单点登录
  7. 怎么使用PHP获取用户客户端真实IP的解决方案呢?
  8. Cordova 3.0 Plugin 安装 及&quot;git&quot; command line tool is not installed
  9. CoreDate的使用
  10. Win32的绘图消息大集合
  11. CI的知识点
  12. NGUI学习笔记(三):屏幕自适应
  13. VMware10.0.4下 CentOS 6.5 cmake安装 MySQL 5.5.32
  14. UEFI引导修复教程和工具
  15. ExtJS4.2学习(6)——基础知识之proxy篇
  16. C指针
  17. 【工具篇】利用DBExportDoc V1.0 For MySQL自动生成数据库表结构文档
  18. C# - Dictionary join keys or join Values
  19. Linux学习之路(三)Shell脚本初探
  20. PID控制器介绍

热门文章

  1. 使用ClassyShark压缩你的项目
  2. 部分和(partial sum)在算法求解中的作用
  3. 微信端 h5 视频 video 自动播放
  4. 23、uevent/hotplug热拔插机制
  5. 在此页上的 ActiveX 控件和本页上的其它部份的交互可能不安全
  6. ZOJ 3168 Sort ZOJ7 水
  7. js进阶 11-21 纯css实现选项卡
  8. Android String与十六进制数互转
  9. 从程序员的角度分析微信小程序(编程语言:用到什么学什么)
  10. 忙里偷闲( ˇˍˇ )闲里偷学【C语言篇】——(8)枚举、补码