WPF 网格上的底部边框

发布于 2024-09-18 09:23:53 字数 1080 浏览 4 评论 0原文

我想在网格中的每一行上设置一个底部边框,但只能找到如何在每个单元格周围放置所有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

墟烟 2024-09-25 09:23:53

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

氛圍 2024-09-25 09:23:53

我很幸运,通过在网格节点周围包含一个带有 BorderThickness="0 1 0 1" 的边框节点,将底部边框放在整行上。像这样:

Border Style="{StaticResource ItemBorderStyle}" BorderThickness="0 1 0 1"
            Grid Style="{StaticResource GridItemStyle}"

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:

Border Style="{StaticResource ItemBorderStyle}" BorderThickness="0 1 0 1"
            Grid Style="{StaticResource GridItemStyle}"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文