行高设置为“的WPF网格布局面板;“自动”;
我想有一个网格,在顶部和底部有一行,其中有标签或按钮。在中间,我计划使用列表框。我希望列表框展开以使用所有可用空间。最好不要硬编码其他两行的高度。我的XAML在下面。如何使中间部分自动展开?谢谢行高设置为“的WPF网格布局面板;“自动”;,wpf,layout,grid,Wpf,Layout,Grid,我想有一个网格,在顶部和底部有一行,其中有标签或按钮。在中间,我计划使用列表框。我希望列表框展开以使用所有可用空间。最好不要硬编码其他两行的高度。我的XAML在下面。如何使中间部分自动展开?谢谢 <UserControl x:Class="WpfApplication1.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http
<UserControl x:Class="WpfApplication1.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Row="0"
Grid.ColumnSpan="3"
Content="Top Row" />
<ListBox Grid.Row="1"
Grid.ColumnSpan="3" />
<Label Grid.Row="2"
Grid.ColumnSpan="3"
Content="Bottom Row" />
</Grid>
更换中间部分
<RowDefinition Height="Auto" />
与
尝试将中间一行设置为此
<RowDefinition Height="*" />
非常感谢。“非常有帮助。”内特。“捷径甚至比这更复杂。在本例中,您不需要更多内容,但如果您有一个复杂的网格,其中需要多个行或列以不同的比例展开,则其中一个可能为“2”,另一个可能为“5*”。如果将两行都放在“”(这是表示1的快捷方式),那么这两行将在它们之间相等地分割展开的空间。干杯,汉克斯·贝里尔。那很有趣。
<RowDefinition Height="*" />