我有一个(简化的)2x2 网格,里面有三个控件。左侧控件横跨两行。

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition></ColumnDefinition>
        <ColumnDefinition></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <GridSplitter Grid.Row="0" Grid.Column="1" Height="4" Background="Gray"
                  HorizontalAlignment="Stretch" VerticalAlignment="Bottom"></GridSplitter>
    <GridSplitter Grid.Row="0" Grid.Column="1" Width="4" Background="Gray" Grid.RowSpan="2"
                  HorizontalAlignment="Left" VerticalAlignment="Stretch"></GridSplitter>
    <!-- Simplified content -->
    <Button Grid.Row="0" Grid.Column="0" Grid.RowSpan="2">Content</Button>
    <Button Grid.Row="0" Grid.Column="1">Content</Button>
    <Button Grid.Row="1" Grid.Column="1">Content</Button>
</Grid>
我不明白为什么这些分离器不起作用。

最佳答案

我建议在内容后面定义 GridSplitter

<Button Grid.Row="0" Grid.Column="0" Grid.RowSpan="2">Content</Button>
<Button Grid.Row="0" Grid.Column="1">Content</Button>
<Button Grid.Row="1" Grid.Column="1">Content</Button>
<GridSplitter Grid.Row="0" Grid.Column="1" Height="4" Background="Gray"
              HorizontalAlignment="Stretch" VerticalAlignment="Bottom"></GridSplitter>
<GridSplitter Grid.Row="0" Grid.Column="1" Width="4" Background="Gray" Grid.RowSpan="2"
              HorizontalAlignment="Left" VerticalAlignment="Stretch"></GridSplitter>

关于wpf - 拉伸(stretch)分离器不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5361993/

10-10 16:08