tesrt
Topic Author
Posts: 7
Joined: 08 Mar 2020, 15:17

Sort a GridView Column When a Header Is Clicked

23 Apr 2020, 16:02

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

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Sort a GridView Column When a Header Is Clicked

24 Apr 2020, 19:46

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).

Who is online

Users browsing this forum: No registered users and 0 guests