【发布时间】:2016-01-22 10:35:12
【问题描述】:
在我的 WPF 应用程序中,我有一个 ListView 包含部分分组的文档:
myitems.Add(new Data("document_1", "section_1"));
myitems.Add(new Data("document_1", "section_2"));
myitems.Add(new Data("document_2", "one_and_only_section"));
lv.ItemsSource = myitems;
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(lv.ItemsSource);
view.GroupDescriptions.Clear();
view.GroupDescriptions.Add(new PropertyGroupDescription("document");
这会导致大致看起来像
< document_1
section_1
section_2
< document_2
one_and_only_section
理论上这很好,但是如果所有内容都折叠起来,选择“one_and_only_section”项非常繁琐,因为它需要单击两次(第一次在“document_2”上,第二次在“one_and_only_section”上)。理想情况下,document_2 不应以与document_1 相同的方式分组:
< document_1
section_1
section_2
document_2
因此,如果组中只有一个元素,则不应使用扩展器来显示该元素。如果被选中,它应该表现得好像“one_and_only_section”被选中了。
这对ListView 可行吗?
【问题讨论】: