WPF 网格线
代码:
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Canvas>
<Canvas.Background>
<VisualBrush
TileMode="Tile" Viewbox="0,0,50,50" ViewboxUnits="Absolute" Viewport="0,0,50,50" ViewportUnits="Absolute">
<VisualBrush.Visual>
<Rectangle Width="50" Height="50" Stroke="DarkGray" StrokeDashArray="5 3" StrokeThickness="1"/>
</VisualBrush.Visual>
</VisualBrush>
</Canvas.Background>
</Canvas>
</Grid>
</Window>
效果: