I've been writing a hobby project in WinUI 3 recently and have run into some trouble.
In my app, I have a GridView
that's bound in XAML to an ObservableCollection
, as recommended in the WinUI documentation. This works great, but now I need to be able to sort and filter the items in the GridView
and it's unclear what the most "correct" or idiomatic way of going about this is.
Googling reveals that WPF has some bits in CollectionViewSource
to handle this, but those appear to have been removed in WinUI.
Currently the only thing I've founded that works is to remove the XAML binding, change the ObservableCollection
to a List
, and then when the user sorts, manually set the GridView
's source to null
followed by setting the source to a sorted version of the List
. If I'm not mistaken this breaks virtualization in the GridView
though, so it doesn't seem like what I'm supposed to be doing.
I would greatly appreciate any insight on this.