我正在尝试将一个项目列表分组到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;
最后我绑定到了这个对象的List(我想在族字段中对该字符串进行分组,该字符串出现在组头中:
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; }
}
我没做什么或做错了什么?
答案 0 :(得分:2)