开发者

DataGrid error when selecting a row

开发者 https://www.devze.com 2023-02-19 17:22 出处:网络
The following problem is not simple to explain. I have a Window which contains a DataGrid, and a ViewModel for the window.

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开发者_JS百科 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消