我有一個ObservableCollection(OF T),其中 「T」 是EF的實體一個ListView數據源。 要添加/編輯項目,使用IEditableCollectionView。它完美的作品。問題是取消修改現有項目的操作。IEditableCollectionView&的EntityFramework
Private Sub edit_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles ListBoxMain.MouseDoubleClick
If ListBoxMain.SelectedItem Is Nothing Then
MessageBox.Show("No item is selected")
Return
End If
Dim editableCollectionView As IEditableCollectionView = TryCast(ListBoxMain.Items, IEditableCollectionView)
Dim win As New ChangeItemWindow()
editableCollectionView.EditItem(ListBoxMain.SelectedItem)
win.DataContext = ListBoxMain.SelectedItem
If CBool(win.ShowDialog()) Then
editableCollectionView.CommitEdit()
Else
editableCollectionView.CancelEdit()
End If
End Sub
的方法「editableCollectionView.CancelEdit()」,下面拋出異常:「的CancelEdit不支持當前編輯元件」。 我想看看是什麼讓我的財產「CanCancelEdit」,並且是「假的」。
謝謝。
什麼是實現IEditableCollectionView類?它是你的嗎? – Crono