Page 1 of 1

Sort a GridView Column When a Header Is Clicked

Posted: 23 Apr 2020, 16:02
by tesrt
I'm trying to follow this example to sort a gridview colum when a header is clicked.
https://docs.microsoft.com/en-us/dotnet ... is-clicked

I'm having some trouble doing it:
  • 'CollectionViewSource' does not contain a definition for 'GetDefaultView' -> CollectionViewSource.GetDefaultView(lv.ItemsSource)
  • headerClicked.Column.DisplayMemberBinding as Binding -> can't be converted
  • headerClicked.Column.HeaderTemplate = Resources["HeaderTemplateArrowUp"] as DataTemplate -> Key "HeaderTemplateArrowUp" not found in RessourceDictionary


How could I achive to convert this code from WPF to Noesis ? Is there a way to find this knowledge in a documentation ?
Thanks

Re: Sort a GridView Column When a Header Is Clicked

Posted: 24 Apr 2020, 19:46
by sfernandez
Sorry, but we don't have support in CollectionView for sorting.

I recommed you to just sort the collection bound to ItemsSource:
- create an empty collection
- sort original collection with the required criteria into the new collection
- update the bound collection property with the new collection
This will be the optimal way to get the collection sorted because it will trigger just a single collection changed notification.

In our next 3.0 version we created a couple of behaviors to help with sorting and filtering collections: CollectionSortBehavior and CollectionFilterBehavior (you can find the code in GitHub).