7
我希望在顶部和底部有一行带有标签或按钮的行。在中间我打算使用ListBox。我想要扩展ListBox以使用所有可用空间。不要硬编码其他两行的高度会很好。我的XAML在下面。我怎样才能让中间部分自动展开?谢谢。将行高设置为“自动”的WPF网格布局面板
<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>
谢谢一堆。很有帮助。 – Nate 2010-07-20 21:18:58
@Nate。 “*”快捷键比这更加复杂。在这个例子中,你不需要任何东西,但是如果你有一个复杂的网格,你需要多个行或列以不同的比例展开,你可能会有一个“2 *”,另一个是“5 *”。如果你将它们都放在“*”(这是说1 *的快捷方式),那么这两行将平分它们之间的扩展空间。欢呼 – Berryl 2010-07-20 22:50:43
谢谢贝里尔。这非常有趣。 – Nate 2010-07-21 21:02:33