【发布时间】:2017-10-27 14:57:04
【问题描述】:
我有一个分组的ListCollectionView,它显示在ListBox 中。
<Style x:Key="GroupHeaderStyle" TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<StackPanel>
<Label Content="{Binding Path=Name}"/>
<WrapPanel Orientation="Horizontal">
<ItemsPresenter />
</WrapPanel>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ListBox ItemsSource="{Binding MyElementView, Mode=OneWay}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}" />
</ListBox.GroupStyle>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type model:MyElementViewModel}">
...
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
现在所有元素都以垂直方式列出,但我想将组水平放置,但组内的项目应该垂直列出。我怎么可能意识到?
【问题讨论】:
标签: c# wpf listbox icollectionview