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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.