DataGrid edition 'EditItem' is not allowed for this view` when bound to a WPF DataGrid

后端 未结 8 1529
醉酒成梦
醉酒成梦 2020-12-09 17:03

I\'ve been reading about this at least for 4 hours, and seems to be the list type, but I have a situation:

A ObservableCollection that has a collection property.

相关标签:
8条回答
  • 2020-12-09 17:23

    I tried this and the problem is that you have initialized your Level2 collection as Hashset<>. IEditableCollectionView.EditItem() throws this error while trying to update item in Hashset<>. I initialized the collection as List<> and it was working fine.

    I am not sure why it is not able to update item in hashset, need to look deeper into it. But changing the Hashset<> to List<> will fix this error.

    Hope it helps

    Thanks

    0 讨论(0)
  • 2020-12-09 17:30

    In shorter way you can write:

    DataGrid.BeginningEdit += (s, ss) => ss.Cancel = true;
    
    0 讨论(0)
提交回复
热议问题