WPF中的DataGrid实现边框的方法,我参考资料后自己画了下,一种方法是:使用Border控件,另一种就是使用Path手动画。
方法一:使用Path画表格
<Path Fill="WhiteSmoke" Stroke="Silver" StrokeThickness="1px">
<Path.Data>
<GeometryGroup>
<RectangleGeometry Rect="50,50,450,510"></RectangleGeometry>
<LineGeometry StartPoint="50,80" EndPoint="500,80"></LineGeometry>
<LineGeometry StartPoint="50,110" EndPoint="500,110"></LineGeometry>
<LineGeometry StartPoint="50,140" EndPoint="500,140"></LineGeometry>
<LineGeometry StartPoint="50,170" EndPoint="500,170"></LineGeometry>
<LineGeometry StartPoint="50,200" EndPoint="500,200"></LineGeometry>
<LineGeometry StartPoint="50,230" EndPoint="500,230"></LineGeometry>
<LineGeometry StartPoint="50,260" EndPoint="500,260"></LineGeometry>
<LineGeometry StartPoint="50,290" EndPoint="500,290"></LineGeometry>
<LineGeometry StartPoint="50,320" EndPoint="500,320"></LineGeometry>
<LineGeometry StartPoint="50,350" EndPoint="500,350"></LineGeometry>
<LineGeometry StartPoint="50,380" EndPoint="500,380"></LineGeometry>
<LineGeometry StartPoint="50,410" EndPoint="500,410"></LineGeometry>
<LineGeometry StartPoint="50,440" EndPoint="500,440"></LineGeometry>
<LineGeometry StartPoint="50,470" EndPoint="500,470"></LineGeometry>
<LineGeometry StartPoint="50,500" EndPoint="500,500"></LineGeometry>
<LineGeometry StartPoint="50,530" EndPoint="500,530"></LineGeometry>
<LineGeometry StartPoint="250,50" EndPoint="250,560"></LineGeometry>
</GeometryGroup></Path.Data>
</Path>大致效果:
方法二:使用border,很多高手已经演示过了。在下只是东施效颦。
<Grid Grid.Column="0" Name="stat" Margin="50,50" >
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Border Grid.Row="0" BorderThickness="1,1,1,0" Grid.Column="0" ></Border>
<Border Grid.Row="0" BorderThickness="0,1,1,0" Grid.Column="1" ></Border>
<Border Grid.Row="1" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="1" BorderThickness="0,1,1,0" Grid.Column="1"></Border><Border Grid.Row="2" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="2" BorderThickness="0,1,1,0" Grid.Column="1"></Border><Border Grid.Row="3" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="3" BorderThickness="0,1,1,0" Grid.Column="1"></Border>
<Border Grid.Row="4" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="4" BorderThickness="0,1,1,0" Grid.Column="1"></Border>
<Border Grid.Row="5" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="5" BorderThickness="0,1,1,0" Grid.Column="1"></Border>
<Border Grid.Row="6" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="6" BorderThickness="0,1,1,0" Grid.Column="1"></Border>
<Border Grid.Row="7" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="7" BorderThickness="0,1,1,0" Grid.Column="1"></Border>
<Border Grid.Row="8" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="8" BorderThickness="0,1,1,0" Grid.Column="1"></Border>
<Border Grid.Row="9" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="9" BorderThickness="0,1,1,0" Grid.Column="1"></Border>
<Border Grid.Row="10" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="10" BorderThickness="0,1,1,0" Grid.Column="1"></Border><Border Grid.Row="11" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="11" BorderThickness="0,1,1,0" Grid.Column="1"></Border>
<Border Grid.Row="12" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="12" BorderThickness="0,1,1,0" Grid.Column="1"></Border>
<Border Grid.Row="13" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="13" BorderThickness="0,1,1,0" Grid.Column="1"></Border>
<Border Grid.Row="14" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="14" BorderThickness="0,1,1,0" Grid.Column="1"></Border>
<Border Grid.Row="15" BorderThickness="1,1,1,0"></Border>
<Border Grid.Row="10" BorderThickness="0,1,1,0" Grid.Column="1" Margin="0,0,0,110"></Border>
<Border Grid.Row="16" BorderThickness="1,1,1,1"></Border>
<Border Grid.Row="12" BorderThickness="0,1,1,1" Grid.Column="1" Margin="0,0,0,79"></Border>
</Grid>
本人菜鸟级别,请大家多多指教,如有更好的方法大家多多分享。O(∩_∩)O谢谢。
转载于:https://www.cnblogs.com/Cindys/archive/2011/04/20/2022525.html