[英]dashed lines for border of gridsplitter wpf
Is there a way to have my border rather than have a solid line around it become dashed lines? 有没有办法让我的边界而不是周围的实线变成虚线? I only want it to appear on the left and right side the top and bottom should be nothing.
我只希望它出现在左侧和右侧,顶部和底部应该没有任何内容。
<Grid Grid.IsSharedSizeScope="True">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="A" Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition SharedSizeGroup="A" Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Content="Shnarf Left" Background="Azure" Grid.Column="0"/>
<TextBlock Text="Shnarf Middle" Background="Lavender" Grid.Column="2" TextWrapping="Wrap"/>
<Label Content="Shnarf Right" Background="Moccasin" Grid.Column="4"/>
<GridSplitter Grid.Column="1" Width="8"
HorizontalAlignment="Center" VerticalAlignment="Stretch" ShowsPreview="True" BorderBrush="Black" BorderThickness="1,0,1,0"/>
<GridSplitter Grid.Column="3" Width="8" Background="DarkSlateBlue"
HorizontalAlignment="Center" VerticalAlignment="Stretch" ShowsPreview="True"/>
</Grid>
The below code works fine & you can customize it as you please ! 以下代码可以正常工作,您可以根据需要自定义它! note that the Viewport determines the size of the dashes in the lines.
请注意,视口将确定行中虚线的大小。 In this case, it generates eight-pixel dashes.
在这种情况下,它将生成八个像素的虚线。 Viewport="0,0,4,4" would give you four-pixel dashes.
Viewport =“ 0,0,4,4”将为您提供四像素虚线。 For Border:
对于边界:
<Border BorderThickness="1,0,1,1">
<Border.BorderBrush>
<DrawingBrush Viewport="0,0,8,8" ViewportUnits="Absolute" TileMode="Tile">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="Black">
<GeometryDrawing.Geometry>
<GeometryGroup>
<RectangleGeometry Rect="0,0,50,50" />
<RectangleGeometry Rect="50,50,50,50" />
</GeometryGroup>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Border.BorderBrush>
<TextBlock Text="Border Content!" Margin="5"/>
</Border>
For GridSplitter : 对于GridSplitter:
<Style x:Key="GridSplitterStyle1" TargetType="{x:Type GridSplitter}">
<Setter Property="Background" Value="Yellow"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridSplitter}">
<Border BorderThickness="1,1,1,1">
<Border.BorderBrush>
<DrawingBrush Viewport="0,0,8,8" ViewportUnits="Absolute" TileMode="Tile">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="Red">
<GeometryDrawing.Geometry>
<GeometryGroup>
<RectangleGeometry Rect="0,0,50,50" />
<RectangleGeometry Rect="50,50,50,50" />
</GeometryGroup>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Border.BorderBrush>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.