Hello!
It turns out that XamGrid ignores column's IsSorted property when the items source is a ListCollectionView. It allows sorting the table later on, when the user clicks on the header, but initial state is not as expected.
I have attached a sample project that has two identical xamGrids that differ only by item source binding. The first one has the initial sorting enabled, but the second one doesn't.
Hello Anton,
I have been looking into your sample and I can say that the behavior you have is expected since the XamGrid uses the ListCollectionView’s SortDescriptions and when you select different items the SortDescriptions are cleared, so I handled the ListCollectionView’s CurrentChanged event and add the SortDescription again. I modified your sample and attached it.
Hope this helps you.
Any progress on the issue?
Hello Stefan,
I've come across yet another strange issue with ListCollectionView. Say we've got a list of "folders" and each of them has a list of "users" inside. On my page I display a ListBox with folders, and the selected folder's contents is displayed by XamGrid.
The trouble is, when I change the selected folder, XamGrid loses information about sorted column and direction. This only happens when I'm binding to a ListCollectionView.
Please have a look at the attached sample application that reproduces the matter. Select some item from the list in the left and notice the column getting unsorted. If I change the binding from FilteredItems to just Items, it works as expected.
I've managed to work this around by creating a Click handler in the listbox, finding the selected column and re-setting it after changing the SelectedFolder property. However, this is clearly a dirty hack and I want a somewhat better solution that does not require handlers and works with bindings.
Best regards,AntonK
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Thank you very much, Stefan!That worked like a charm :)