2
我使用ListBox
来显示我认为的ObservableCollection
的内容。在我简单的例子,我只是用图像像每个项目:使用ListBox和StackPanel的所有可用空间作为ItemsPanelTemplate
<Window>
<Window.Resources>
<DataTemplate DataType="{x:Type viewModel:HealthCriterionViewModel}">
<Image VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Source="Optionsh.png" Stretch="Fill" />
</DataTemplate>
</Window.Resources>
<ListBox ItemsSource="{Binding HealthCriteria}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Window>
HealthCriteria
是HealthCriterionViewModel
类型的集合。
我得到的是这样的:
我想是这样的(拉伸图像水平和垂直方向使用所有可用空间):
我怎样才能做到这一点?