Marko Marko - 1 year ago 235
C# Question

Bottom borders on WPF Grid

I've got a pretty simple question regarding the WPF Grid Control.

I'd like to set a bottom border on each row in the grid, but can only find how to put all 4 borders around each cell.. my code is quite simple

<Grid Height="174" HorizontalAlignment="Left" Margin="23,289,0,0" Name="grid2" VerticalAlignment="Top" Width="730">
<RowDefinition Height="45" />
<RowDefinition Height="25" />
<RowDefinition Height="25" />
<RowDefinition Height="25" />
<RowDefinition Height="25" />
<RowDefinition Height="25" />
<ColumnDefinition Width="255" />
<ColumnDefinition Width="95" />
<ColumnDefinition Width="95" />
<ColumnDefinition Width="95" />
<ColumnDefinition Width="95" />
<ColumnDefinition Width="95" />

For another grid I'm using that needs all four borders, I'm using

<Border Grid.Column="0" Grid.Row="0" BorderBrush="#61738B" BorderThickness="1" />

P.S. The contents of the grid are some labels, textboxes, etc.. if that matters at all.

Appreciate any pointers.


Answer Source

On a Border control You can do BorderThickness="0 0 0 1" to only have a bottom border shown.

Top and bottom border thickness of 5, left and right border thickness of 0

BorderThickness="0 5"

Top and bottom border thickness of 0, left and right border thickness of 5

BorderThickness="5 0"

Border Thickness - Left: 1, Top: 2, Right:3, Bottom: 4

BorderThickness="1 2 3 4"

Hope this helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download