archie456
Member
- Joined
- Apr 19, 2020
- Messages
- 11
- Programming Experience
- 1-3
Hi,
I have a ListView bound to a view model, I set up groupings in the list view using PropertyGroupDescriptions:
To then sort the groups using this:
This all works nicely, but I'd like to sort one of the groups by my own custom method, but I can't see how I can specify this:
But I can't see any way to sort a SortDesciption using a custom sort.
I'd appreciate some pointers on the best way to do this.
Thanks.
I have a ListView bound to a view model, I set up groupings in the list view using PropertyGroupDescriptions:
C#:
BrowserItemCollectionView = CollectionViewSource.GetDefaultView(myCollection);
//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);
To then sort the groups using this:
C#:
//Setup Sorting
BrowserItemCollectionView.SortDescriptions.Add(new SortDescription(nameof(BrowserItem.L1group), ListSortDirection.Ascending));
BrowserItemCollectionView.SortDescriptions.Add(new SortDescription(nameof(BrowserItem.L2group), ListSortDirection.Ascending));
BrowserItemCollectionView.SortDescriptions.Add(new SortDescription(nameof(BrowserItem.L3group), ListSortDirection.Ascending));
C#:
This all works nicely, but I'd like to sort one of the groups by my own custom method, but I can't see how I can specify this:
C#:
BrowserItemCollectionView.SortDescriptions.Add(new SortDescription(nameof(BrowserItem.L1group), MYSORTING));
But I can't see any way to sort a SortDesciption using a custom sort.
I'd appreciate some pointers on the best way to do this.
Thanks.