拉伸分离器不起作用

发布于 2024-10-24 00:57:48 字数 1113 浏览 0 评论 0原文

我有一个(简化的)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>

我不明白为什么这些分离器不起作用。

I have a (simplified) 2x2 Grid with three controls inside. The left control strechtes over both rows.

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

I can't figure out why these splitters do not work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

め七分饶幸 2024-10-31 00:57:48

我建议在内容后面定义 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>

I suggest to define the GridSplitter behind the 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>
<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>
行至春深 2024-10-31 00:57:48

这对我有用 -

  <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition Width="auto"></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition></RowDefinition>
                <RowDefinition Height="auto"></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>
            <GridSplitter Grid.Row="1" Grid.Column="2" Height="4" Background="Gray"
                      HorizontalAlignment="Stretch" VerticalAlignment="Center"></GridSplitter>
            <GridSplitter Grid.Row="0" Grid.Column="1" Width="4" Background="Gray" Grid.RowSpan="3"
                      HorizontalAlignment="Center" VerticalAlignment="Stretch"></GridSplitter>
            <Button Grid.Row="0" Grid.Column="0" Grid.RowSpan="3">Content</Button>
            <Button Grid.Row="0" Grid.Column="2">Content</Button>
            <Button Grid.Row="2" Grid.Column="2">Content</Button>       

        </Grid>

This one works for me -

  <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition Width="auto"></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition></RowDefinition>
                <RowDefinition Height="auto"></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>
            <GridSplitter Grid.Row="1" Grid.Column="2" Height="4" Background="Gray"
                      HorizontalAlignment="Stretch" VerticalAlignment="Center"></GridSplitter>
            <GridSplitter Grid.Row="0" Grid.Column="1" Width="4" Background="Gray" Grid.RowSpan="3"
                      HorizontalAlignment="Center" VerticalAlignment="Stretch"></GridSplitter>
            <Button Grid.Row="0" Grid.Column="0" Grid.RowSpan="3">Content</Button>
            <Button Grid.Row="0" Grid.Column="2">Content</Button>
            <Button Grid.Row="2" Grid.Column="2">Content</Button>       

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