I have a Grid like this:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0">Row 0, Column 1</TextBlock>
<TextBlock Grid.Row="1" Grid.Column="0">Row 1, Column 1</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0">Row 2, Column 1</TextBlock>
<TextBlock Grid.Row="3" Grid.Column="0">Row 3, Column 1</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Grid.RowSpan="4">Column 1</TextBlock>
</Grid>
I am not going to actually use TexBlocks in the real application, I used them to make the example easier. Basically I want to Set the border that devides all the content in Column 0 from Column 1.
How do you do that?
The grid-column-start longhand is set to the value before the slash, and the grid-column-end longhand is set to the value after the slash. Each <grid-line> value can be specified as: either the auto keyword. or a <custom-ident> value.
You can specify the width of a column by using a keyword (like auto ) or a length (like 10px ). The number of columns is determined by the number of values defined in the space-separated list.
One of the best ways to display a Border
is to use a Border
element. You can just declare it behind the other content:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Border Grid.Column="1" Grid.RowSpan="4" BorderBrush="Black"
BorderThickness="1,0,0,0" Background="{x:Null}" />
<TextBlock Grid.Row="0" Grid.Column="0">Row 0, Column 1</TextBlock>
<TextBlock Grid.Row="1" Grid.Column="0">Row 1, Column 1</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0">Row 2, Column 1</TextBlock>
<TextBlock Grid.Row="3" Grid.Column="0">Row 3, Column 1</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Grid.RowSpan="4">Column 1</TextBlock>
</Grid>
There's a number of ways to accomplish it, easiest, just draw a line (except I cheated and used a shape...I know, horrible of me right? But you get the idea..) Hope this helps.
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Rectangle Grid.RowSpan="4" Width="1" Fill="Red" HorizontalAlignment="Right"/>
<TextBlock Grid.Row="0" Grid.Column="0">Row 0, Column 1</TextBlock>
<TextBlock Grid.Row="1" Grid.Column="0">Row 1, Column 1</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0">Row 2, Column 1</TextBlock>
<TextBlock Grid.Row="3" Grid.Column="0">Row 3, Column 1</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Grid.RowSpan="4">Column 1</TextBlock>
</Grid>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With