Hi,
I actually have two questions. Attached is a sample project to help reproduce my "problem". The project has one xamDataGrid and two Microsoft WPF DataGrid. There's a view model exposing an ObservableCollection. I need to implement navigation logic in the view model, so I have a few buttons bound to Commands in the view model that will move the active item by calling methods on the default ICollectionView of the ObservableCollection. (e.g. calling ListCollectionView.MoveCurrentToNext()). All three grids have IsSynchronizedWithCurrentItem set to true.
1. The xamDataGrid does not seem to pick up the ICollectionView.CurrentItem if it is bound to the ObservableCollection. Is it because xamDataGrid creates its own internal view via the RecordManager?
Steps to reproduce:
To get around the problem, I expose the ICollectionView of the ObservableCollection from the view model and bind that to the xamDataGrid. Now the xamDataGrid will also select the current item.
2. Now that I bind the xamDataGrid to "FoosView" (ListCollectionView of the ObservableCollection), navigating with the Next/Previous buttons seems to work fine. Sorting the Microsoft DataGrid will update the corresponding xamDataGrid and navigating with the Next/Previous buttons continue to work as expected. But if I were to sort the xamDataGrid instead, the sorting on the Microsoft DataGrid does not update.
Is there any way I can get xamDataGrid to update the underlying ListCollectionView when sorting happens?
What I need to do is to implement Next/Previous in the view model, where Next will move the active item "down" based on the display order. But because xamDataGrid does not seem to update the ListCollectionView, as soon as I change the sort order, Next will move the active item "up". I thought about using DataPresenterCommands.RecordNext, but it didn't work for me because RecordNext will clear the selected items, whereas I need to keep the selected items even when active item is moved. Plus, I don't really know how to use the DataPresenterCommands from the view model because they are RoutedCommands.
Thanks in advance for any help!
Harold
I ended up handling the sorted event and manually reset the sort descriptions in the underlying ListCollectionView.
Thanks,
Hello Harold,
We are still following this forum thread.
Please do not hestitate to contact us if you have any other questions with this matter.
Hello,
I have been looking into your post and according to your first issue it seems that when you work with the CollectionViewSource, the XamDataGrid uses its ‘CurrentItem’ property. This is the current implementation of the XamDataGrid. This is why you are able to synchronize the three grid controls. The ObservableCollection does not provide such kind of functionality.
According to your second question I can suggest you look through the following forum thread where Stefan has attach a sample on how to synchronize two XamDataGrids :
http://es.infragistics.com/community/forums/p/62641/319495.aspx
If you need any further assistance on this matter, feel free to ask.