【问题标题】:Designing Grid wpf设计网格 wpf
【发布时间】:2016-02-25 19:06:43
【问题描述】:

我正在使用 C#(WPF) 进行编程。我使用 4 行网格如下:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition>
        <RowDefinition>
        <RowDefinition>
        <RowDefinition>
    </Grid.RowDefinitions>

    <!-- Height of this row is related to its content -->
    <Grid Row="0">
    </Grid>

    <!-- Height of this row is related to its content -->
    <Grid Row="1">
    </Grid>

    <!-- Remaining of Height should be used here... -->
    <Grid Row="2">
    </Grid>

    <!-- Height of this row is related to its content and this row should be stick to bottom of page  -->
    <Grid Row="3">
    </Grid>

</Grid> 

根据我的 XAML 代码中的 cmets:

  • 在 Row=0 中,高度与其内容相关
  • 在 Row=1 中,高度与其内容相关
  • Row=3 中,Height 与其内容相关,此行应贴在页面底部
  • 在 Row=2 中,此处应使用剩余高度

如何根据四个命名条件调整行定义?

更多想象请看这张图片:

【问题讨论】:

    标签: wpf grid rowdefinition


    【解决方案1】:

    我现在不在 Windows 上,所以我无法测试它,但我会尝试这样的。

    在您的 RowDefinition 中:

    <RowDefinition Height="Auto"/>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="*"/>
    <RowDefinition Height="Auto"/>
    

    Height="Auto",表示该行将只占用其内容所需的高度。

    Height="*",表示该行将占用所有剩余的可用高度。

    【讨论】:

    • 这行得通。具有* 高度的第 3 行将确保第 4 行始终被推到页面底部。
    猜你喜欢
    • 2023-03-04
    • 2011-05-06
    • 1970-01-01
    • 1970-01-01
    • 2013-11-10
    • 1970-01-01
    • 1970-01-01
    • 2019-12-12
    • 2021-04-28
    相关资源
    最近更新 更多