【发布时间】:2014-08-07 09:01:41
【问题描述】:
我正在尝试在 WPF 列表视图中对项目列表进行分组 - 它工作正常,但我无法显示扩展器标题。
我设置分组样式如下:
<!-- Styles the groups -->
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander BorderBrush="LightBlue"
BorderThickness="1"
IsExpanded="True"
Name="groupExpander"
Header="{Binding Family}">
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
并且列表视图项目源绑定在后面的代码中:
//group by shape family
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(GetShapes());
PropertyGroupDescription groupDescription = new PropertyGroupDescription("Family");
view.GroupDescriptions.Add(groupDescription);
ImagesListView.ItemsSource = view;
最后我绑定到这个对象的列表(我想在家庭字段上分组,这个字符串出现在组标题中:
public class Shape
{
public int ID { get; private set; }
public byte[] Image { get; private set; }
public string Description { get; private set; }
public string Family { get; private set; }
}
我没有做什么或做错了什么?
【问题讨论】: