[英]Cant get list view group expander header to display
I am trying to group a list of items in a WPF list view - its working fine but I cant get the expanders header to show. 我正在尝试在WPF列表视图中对项目列表进行分组-正常工作,但无法显示Expanders标头。
I set the group style as follows: 我将组样式设置如下:
<!-- 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>
and the list view items source is bound in the code behind: 并且列表视图项源绑定在后面的代码中:
//group by shape family
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(GetShapes());
PropertyGroupDescription groupDescription = new PropertyGroupDescription("Family");
view.GroupDescriptions.Add(groupDescription);
ImagesListView.ItemsSource = view;
And finally I am binding to a List of this object (I want to group on the family field with this string appearing in the group header: 最后,我将绑定到该对象的列表(我想对这个族进行分组,并在组头中显示该字符串:
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; }
} }
What am I not doing or doing wrong? 我在做什么或做错了什么?
You need to change 你需要改变
Header="{Binding Family}"
to 至
Header="{Binding Name}"
Each group is a CollectionViewGroup
where Name
is the value that you group by 每个组都是一个
CollectionViewGroup
,其中Name
是您分组依据的值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.