Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bottom borders on WPF Grid

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..

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

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.

like image 242
Marko Avatar asked Sep 12 '10 05:09

Marko


People also ask

How do you make a grid border in WPF?

Elements in WPF do not have a border property. To place a border around an element, WPF provides the Border element. Similar to other WPF elements, the Border has Width, Height, Background and HorizontalAlignment and VerticalAlignment properties.

How do you add a border in XAML?

To apply a border to a XAML element, you can place the element within a Border element, The BorderThickness and BorderBrush are two main properties of a Border The BorderBrush property represents the brush that is used to draw the border. The BorderThickness property represents the thickness of the border.


1 Answers

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!

like image 171
Mark Carpenter Avatar answered Sep 30 '22 21:09

Mark Carpenter