【问题标题】:How can I implement the equivalent of a split view container in WPF?如何在 WPF 中实现等效的拆分视图容器?
【发布时间】:2019-12-31 03:49:03
【问题描述】:

我希望将 WinForms 应用程序移植到 WPF。我有一个经典的拆分视图容器,需要在 WPF 中复制。不是汉堡菜单等,而是带有滑块的完整拆分视图,用户可以根据需要使用它来水平或垂直调整大小。

我无法想象我是第一个需要这个的人,但对于我的一生,我找不到解决方案。我想我只是不知道在搜索时使用的正确关键字。任何建议表示赞赏。 TIA。

【问题讨论】:

  • 我不熟悉 WinForms,但是看看 GridSplitter。
  • 这就是我要找的魔法酱。我以前尝试过,但它没有做任何事情。但是,我根据您的建议进行了更深入的研究,这正是我所需要的。感谢您的意见。

标签: c# wpf wpf-controls


【解决方案1】:

正如 gdir 的评论所说,试试 GridSplitter。

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition Width="5" />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>

    <Rectangle Fill="Blue" />
    <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
    <Rectangle Fill="Red" Grid.Column="2" />
</Grid>

它需要位于它自己的网格单元格中,您可以使用ResizeDirection 属性在行和列之间进行切换。

【讨论】:

    猜你喜欢
    • 2023-03-19
    • 1970-01-01
    • 2019-11-12
    • 2016-07-07
    • 2014-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    相关资源
    最近更新 更多