Hi,
I'm having persistent issues with the grid when I try to set a saved list of selected rows when loading data into the grid in my WPF project.
The basic logic is as follows:
1. Load the ViewModel, get saved data and populate an observable collection for the ItemsSource property on the grid.
2. Set the SelectedItems property in the same procedure
3. Explicitly call the property changed event for the selected items collection.
I have implemented a custom behaviour to allow the RadGridView to use the Extended selection option and retain all selected items, and it works perfectly in this project and others, when setting the collection in the UI and binding to the collection in the ViewModel.
I put an OnCollectionChanged event onto my selected items collection, and while it gets called as expected when I set the items, it also seems to get called after the grid itself is rendered, which causes the saved selection to be lost.
If I use only a single item, i.e. SelectedItem, this does not get lost, and if I set SelectedItem by using the first line in the collection before setting SelectedItems collection itself, the UI retains the first one, but wipes the others.
I have tried a number of ways to work around this, including trying to fire an event after the selection is overridden but it's proving very tricky to get the right event, and anyway this behaviour should surely not be happening in the first place.
I am attaching a sample project which demonstrates a simpler version of this scenario, with the same problems.
Please advise.