I'm binding a XamDataGrid DataSource to the ICollectionView of an ObservableCollection in my ViewModel. When I remove the CurrentItem of the ICollectionView from the ObservableCollection in the ViewModel, I would like the CurrentItem to select the next object in the ObservableCollection as it appears to the user. If the user performs sorting or grouping on the XamDataGrid, the selection appears to jump around randomly when I remove the CurrentItem from the ObservableCollection, because the "next" item of the ObservableCollection corresponds to the order in which the objects were added to the ObservableCollection, not the order the objects are rendered on the screen inside the XamDataGrid (because of sorting and / or grouping).
I've tried subscribing to my XamDataGrid's Sorting and Grouping events, and populating the ICollectionView's SortDescriptions and GroupDescriptions properties in the event handlers, which seems to synchronize the XamDataGrid with the ObservableCollection, but this seems like it shouldn't be necessary.
Is the XamDataGrid capable of populating my ICollectionView SortDescriptions and GroupDescriptions properties directly, without the need for subscribing to these events? Is there another way of "synchronizing" the order of objects in my ObservableCollection?
Hello,
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking through your post and it seems like that the ICollectionView doesn’t synchronize with the XamDataGrid’s SortDescriptions and GroupByDescriptions. If you want you can explicitly add the Descriptions from the XamDataGrid to the ColectionView on Grouped and Sorted events.
Feel free to write me if you have further questions.
Hi,
In case anyone else is running into this issue, here's the latest: I ended up creating a support issue for this, that was eventually denied by Infragistics. I'm aware that I can write event handlers to synchronize the SortDescriptions and GroupByDescriptions of the ICollectionView myself.
The point of this post, and my support issue, is that I feel that it is unreasonable for Infragistics to expect consumers of XamDataGrid to have to do so.
When binding to an ICollectionView, It would seem that XamDataGrid uses some mechanism other than the ICollectionView to keep track of sorting and grouping. Infragistics should either support binding to an ICollectionView or not, but if it is supported, the entire interface should be supported, including these two collections.
Is XamDataGrid MVVM compatible using ICollectionView? That depends on how much of ICollectionView you care about, and whether you're willing to maintain code to work around inconsistencies in XamDataGrid's implementation.