Reputation: 547
The following problem is not simple to explain. I have a Window which contains a DataGrid, and a ViewModel for the window. The window.DataContext holds the ViewModel. the DataGrid.ItemSource holds an ObservableCollection. DataGrid's RowStyle's IsSelected Property is Binded to an IsSelected property in the PointData.
When I close the window and open a new one... and populate it with the old ViewModel data. Selecting an "old" row throws an annoying Exception which says: "Collection was modified; enumeration operation may not execute"
If anyone has an idea of solving this situation I would truely appreaciate the help. Thanks
Upvotes: 1
Views: 198
Reputation: 50672
Normally this exception occurs when you modify a collection while using IEnumerable (an Enumerator) to loop through the collection. The keyword foreach
uses this interface.
Upvotes: 1