我使用ListView
作为GridView
的ItemTemplate。问题是我无法获取listview中的文本框来填充可用的垂直空间,而是只使用所需的空间:
为什么忽略我设置的VerticalAlignment="Stretch"
?
<ListView Margin="0,0,0,0"
Width="200"
SelectionMode="None">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListView.ItemContainerStyle>
<ComboBox>
<ComboBoxItem Tag="1" Content="1"/>
</ComboBox>
<TextBox AcceptsReturn="True" VerticalAlignment="Stretch" TextWrapping="Wrap" Text="Should fill everything" />
</ListView>
答案 0 :(得分:1)
您必须以这种方式将ListView放在GridLayout中:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ComboBox Grid.Row="0" .... />
<ListView Grid.Row="1" .... />
</Grid>