The documentation on MSDN says about CancelEdit:
CancelEdit sets CurrentEditItem to null and causes the collection view to exit the edit state. If CanCancelEdit is true, CancelEdit also restores the original values of the edited object.
This means: first set CurrentEditItem to null, then if possible restore original values. The implementation in QueryableCollectionView.Editing.cs is slightly different because CurrentEditItem is only set to null if it is an IEditableObject otherwise it throws an exception. In my opinion this is not correct. Of course CancelEdit should only be called on the CurrentEditItem if it is an IEditableObject, but setting CurrentEditItem to null should always be called! So the corrected code must be:
CancelEdit sets CurrentEditItem to null and causes the collection view to exit the edit state. If CanCancelEdit is true, CancelEdit also restores the original values of the edited object.
This means: first set CurrentEditItem to null, then if possible restore original values. The implementation in QueryableCollectionView.Editing.cs is slightly different because CurrentEditItem is only set to null if it is an IEditableObject otherwise it throws an exception. In my opinion this is not correct. Of course CancelEdit should only be called on the CurrentEditItem if it is an IEditableObject, but setting CurrentEditItem to null should always be called! So the corrected code must be:
if
(
this
.CanCancelEdit)
{
CancelEditItem(
this
.CurrentEditItem);
}
this
.CurrentEditItem =
null
;