I'm using the Windows Community Toolkit Datagrid.
I am binding the the datagrid's ItemSource to a grouped CollectionViewSource.
<ctWinUI:DataGrid
ItemsSource="{x:Bind MyCollectioViewSourceView, Mode=OneWay}"
By default groups are sorted alphabetically:
How can I implement custom sorting?
(Note I know how to sort datagrid rows, this is specifically for sorting datagrid groups.)
I have seen similar questions for the WPF datagrid, but the WinUI datagrid is different.
Just order the Source
of the grouped MyCollectioViewSourceView
, e.g.:
CollectionViewSource cvs= new CollectionViewSource();
cvs.IsSourceGrouped = true;
cvs.Source = groupedItems.OrderByDescending(x => x.Key).ToList();