设计网格 wpf
Designing Grid wpf
我正在用 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 代码中的注释:
- Row=0,高度与其内容有关
- Row=1,高度与其内容有关
- Row=3,高度与其内容有关,该行应贴在页面底部
- 在Row=2中,此处应使用Remaining Height
如何根据四个命名条件调整行定义?
更多想象请看这张图:
我现在不在 Windows,所以我无法测试它,但我会尝试这样的事情。
在你的行定义中:
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
Height="Auto",表示该行将只占用其内容所需的高度。
Height="*",表示该行将占用所有可用的剩余高度。
我正在用 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 代码中的注释:
- Row=0,高度与其内容有关
- Row=1,高度与其内容有关
- Row=3,高度与其内容有关,该行应贴在页面底部
- 在Row=2中,此处应使用Remaining Height
如何根据四个命名条件调整行定义?
更多想象请看这张图:
我现在不在 Windows,所以我无法测试它,但我会尝试这样的事情。
在你的行定义中:
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
Height="Auto",表示该行将只占用其内容所需的高度。
Height="*",表示该行将占用所有可用的剩余高度。