ListView CollectionView 排序最低层
ListView CollectionView sort lowest level
我有一个关于如何对 ListView 中的项目进行排序的问题,我认为这很容易,但我似乎无法解决。
ListView 绑定到一个可观察的集合视图模型...通过设置 CollectionViewSource 和设置 GroupDescriptions,列表视图中的项目根据某些属性进行分组:
BrowserItemCollectionView = CollectionViewSource.GetDefaultView(_browser);
//Set up filter
BrowserItemCollectionView.Filter = FilterBrowserItems;
//Set up grouping
PropertyGroupDescription L1PGD = new PropertyGroupDescription(nameof(BrowserItem.L1group));
PropertyGroupDescription L2PGD = new PropertyGroupDescription(nameof(BrowserItem.L2group));
PropertyGroupDescription L3PGD = new PropertyGroupDescription(nameof(BrowserItem.L3group));
BrowserItemCollectionView.GroupDescriptions.Add(L1PGD);
BrowserItemCollectionView.GroupDescriptions.Add(L2PGD);
BrowserItemCollectionView.GroupDescriptions.Add(L3PGD);
然后我对组进行排序:
//Setup Sorting
BrowserItemCollectionView.SortDescriptions.Add(new SortDescription(nameof(BrowserItem.L1group), ListSortDirection.Descending));
BrowserItemCollectionView.SortDescriptions.Add(new SortDescription(nameof(BrowserItem.L2group), ListSortDirection.Descending));
BrowserItemCollectionView.SortDescriptions.Add(new SortDescription(nameof(BrowserItem.L3group), ListSortDirection.Descending));
这很有效,并且按降序对分组进行排序。
我现在要做的是对实际项目进行排序 - 树视图的最低级别的对象。
我使用什么方法对实际列表视图项进行排序?
谢谢。
What method do I use to sort the actual list view items?
您只需将“最低级别”项目的 属性 添加另一个 SortDescription
到 BrowserItemCollectionView.SortDescriptions
:
BrowserItemCollectionView.SortDescriptions.Add(
new SortDescription("PropertyOfItem", ListSortDirection.Descending));
我有一个关于如何对 ListView 中的项目进行排序的问题,我认为这很容易,但我似乎无法解决。
ListView 绑定到一个可观察的集合视图模型...通过设置 CollectionViewSource 和设置 GroupDescriptions,列表视图中的项目根据某些属性进行分组:
BrowserItemCollectionView = CollectionViewSource.GetDefaultView(_browser);
//Set up filter
BrowserItemCollectionView.Filter = FilterBrowserItems;
//Set up grouping
PropertyGroupDescription L1PGD = new PropertyGroupDescription(nameof(BrowserItem.L1group));
PropertyGroupDescription L2PGD = new PropertyGroupDescription(nameof(BrowserItem.L2group));
PropertyGroupDescription L3PGD = new PropertyGroupDescription(nameof(BrowserItem.L3group));
BrowserItemCollectionView.GroupDescriptions.Add(L1PGD);
BrowserItemCollectionView.GroupDescriptions.Add(L2PGD);
BrowserItemCollectionView.GroupDescriptions.Add(L3PGD);
然后我对组进行排序:
//Setup Sorting
BrowserItemCollectionView.SortDescriptions.Add(new SortDescription(nameof(BrowserItem.L1group), ListSortDirection.Descending));
BrowserItemCollectionView.SortDescriptions.Add(new SortDescription(nameof(BrowserItem.L2group), ListSortDirection.Descending));
BrowserItemCollectionView.SortDescriptions.Add(new SortDescription(nameof(BrowserItem.L3group), ListSortDirection.Descending));
这很有效,并且按降序对分组进行排序。
我现在要做的是对实际项目进行排序 - 树视图的最低级别的对象。
我使用什么方法对实际列表视图项进行排序?
谢谢。
What method do I use to sort the actual list view items?
您只需将“最低级别”项目的 属性 添加另一个 SortDescription
到 BrowserItemCollectionView.SortDescriptions
:
BrowserItemCollectionView.SortDescriptions.Add(
new SortDescription("PropertyOfItem", ListSortDirection.Descending));