zoukankan      html  css  js  c++  java
  • 转 给WPF加上格子

    显示效果:

    示例方格查看器

    XAML代码:
    <Canvas Width="752.009766" Height="1192.558594" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
            <Canvas.Resources>
                <DrawingBrush x:Key="MyGridBrushResource" 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>
                                <!-- 横线100整数倍 -->
                                <GeometryDrawing Geometry="M0,0 L10,0">
                                    <GeometryDrawing.Pen>
                                        <Pen Thickness="0.1" Brush="DarkOrange" />
                                    </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>
                                <!-- 竖线100整数倍 -->
                                <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 MyGridBrushResource}"/>
                    <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="348">
                    <Path StrokeThickness="5" Stroke="Orange" StrokeMiterLimit="1"
    Data="F1 M 0.3,66.2 C 0.3,66.2 44.9,33.5 68.5,66.3 C 92.1,99.1 197.2,206.3 274.6,133.2 C 366.8,46.2 378.3,2.7 459.7,25.1"
    />
                </Canvas>
            </Border>

    </Canvas>


    而在此之前初始版本的演示效果为:

    初始版本的显示格效果

  • 相关阅读:
    格式化输出数字
    传教士经验
    集合
    替换
    连接
    填充
    取值
    分割
    创建日历和日期列表
    常用日期格式
  • 原文地址:https://www.cnblogs.com/chuncn/p/1766565.html
Copyright © 2011-2022 走看看