Reputation: 215
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>
Upvotes: 1
Views: 1622
Reputation: 3018
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. 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 :
<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>
Upvotes: 8