【发布时间】:2011-05-03 08:44:13
【问题描述】:
在我的 WPF 应用程序中,我有一个 CollectionViewSource,它为私有 ObservableCollection 提供视图。 CollectionViewSource 有一个 PropertyGroupDescription,它在 ListBox 中用于将数据呈现给用户的偏好。
在 ListBox GroupStyle 中使用包含 Expander Control 的 ControlTemplate,结果非常好。但是,除了组名之外,我还想在扩展器标题中显示每个组中的项目数。关于绑定路径的任何想法?
问候, 利亚姆
<Style x:Key="basicGroupStyle" TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander Header="{Binding Name}" IsExpanded="True">
<ItemsPresenter/>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ListBox ItemsSource="{Binding Source={StaticResource myViewSource}}">
<ListBox.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource basicGroupStyle}"/>
</ListBox.GroupStyle>
</ListBox>
【问题讨论】:
标签: wpf grouping collectionviewsource