我有一个ItemsControl,它的ItemsSource绑定到一个项目列表。每个项目的大小尽可能小,我需要控件和其中的项目拉伸以适应所有可用空间。
我尝试在控件和其项目上(使用样式)将VerticalAlignment设置为Stretch。我还尝试将ItemsControl包装在DockPanel中,并将ItemsControl停靠到底部。如何使ItemsControl动态调整大小?
此外,一些项目的可见性设置为Collapsed(通过相同的样式)。这会影响到这个问题吗?
我尝试在控件和其项目上(使用样式)将VerticalAlignment设置为Stretch。我还尝试将ItemsControl包装在DockPanel中,并将ItemsControl停靠到底部。如何使ItemsControl动态调整大小?
此外,一些项目的可见性设置为Collapsed(通过相同的样式)。这会影响到这个问题吗?
<DockPanel HorizontalAlignment="Stretch">
<ItemsControl DockPanel.Dock="Bottom"
ItemsSource="{Binding Owner.LoadPointCharts}"
HorizontalAlignment="Stretch"
x:Name="ItemsControl">
<ItemsControl.ItemContainerStyle><!--Height="{Binding Path=Height, RelativeSource={RelativeSource AncestorType={x:Type DockPanel}}}"-->
<Style TargetType="ContentPresenter">
<Setter Property="VerticalAlignment"
Value="Stretch" />
<Setter Property="Visibility">
<Setter.Value>
<MultiBinding Converter="{StaticResource CompareIndexToVisibilityConverter}">
<Binding Path="Index" />
<Binding Path="SelectedIndex" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style >
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</DockPanel>