1
votes

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

1
Would help if you would post your xaml with the datagrid and at least the part of the viewmodel which you are binding to.hyp

1 Answers

1
votes

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.