WPF 网格上的底部边框
我想在网格中的每一行上设置一个底部边框,但只能找到如何在每个单元格周围放置所有 4 个边框。
<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>
对于我正在使用的另一个网格,它需要所有四个边框,我正在使用
<Border Grid.Column="0" Grid.Row="0" BorderBrush="#61738B" BorderThickness="1" />
PS网格的内容是一些标签、文本框等。如果这很重要的话。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
Border
控件上,您可以执行BorderThickness="0 0 0 1"
以仅显示底部边框。上下边框厚度为 5,左右边框厚度为 0
BorderThickness="0 5"
上下边框厚度为 0,左右边框厚度为 5
BorderThickness="5 0"
边框厚度 - 左:1,上:2,右:3,下:4
BorderThickness="1 2 3 4"
On a
Border
control You can doBorderThickness="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"
我很幸运,通过在网格节点周围包含一个带有
BorderThickness="0 1 0 1"
的边框节点,将底部边框放在整行上。像这样:I had luck putting a bottom border on a whole row by including a Border Node with
BorderThickness="0 1 0 1"
surrounding the Grid Node. Like this: