I have a simple grid binded to a DataSource (List<MyItems>). The DataSource items have a Status boolean property. When double-clicking the record, I'd like to toggle the value of the Status field. Here is the line from the code-behind in the MouseDoubleClick event of my grid where I toggle the value:
ViewModel.Model[MyGrid.ActiveRecord.Index].Status = !ViewModel.Model[MyGrid.ActiveRecord.Index].Status;
With this code, the value in my ViewModel is correctly toggled between true and false, but the grid doesn't reflect the changes. If I scroll down to the bottom of the grid and come back to the record, the row is shown correctly.
How do can I keep the grid in synch with my ViewModel in that case?
Your MyItems class needs to implement INotifyPropertyChanged, and use an ObservableCollection instead of a list
What if I can't change the type of the collection? This is not my code. Isn't there a way to notify the grid manually?
Re-assigning the Datasource refreshes the checkboxes, but then I loose the state of the grid (some rows are expanded, etc)