2

我尝试以这种方式用边框包围我的网格:

<Border BorderBrush="Black" BorderThickness="2">
<Grid>. . .</Grid>
</Border>

...但是当我这样做时,以前位于我页面顶部的 TextBlock 以及其他网格被推到整个画布上 - 边框完美地包围了我的网格,但它会导致这些副作用。如何在不影响其他控件的情况下添加边框?

我的 XAML 是:

StackPanel
    Grid with 3 columns and four rows)
        TextBlock (GridRow=0, GridCol=0, GridColSpan=3)
        Grid (GridRow=1)
        Grid (GridRow=2)
        Grid (GridRow=3)

更新

感谢达武特;这很好用:

    <Border Grid.Row="1" Padding="4" Margin="4" BorderThickness="2" BorderBrush="Black" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
    <Border Grid.Row="1" Padding="4" Margin="4" Grid.Column="1" BorderThickness="2" BorderBrush="Black" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
    <Border Grid.Row="1" Padding="4" Margin="4" Grid.Column="2" BorderThickness="2" BorderBrush="Black" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
4

0 回答 0