DataGrid Validation, IEditableObject CancelEdit() weird behavior.

Feb 1, 2016 at 7:16 PM
Hi guys,

I've implemented a WPF datagrid and I'm trying to revert the current cell changes when there is already a row containing the cell value.

On CellEditEnding, i verify that there are no cell in error, if so, the current cell need to be reverted so I call CancelEdit on the datacontext.

Here is the problem.

When i enter the cell edit mode via a double click or F2, everything is working fine. If I modify the cell content to a string already existing in other rows, the cell become in error mode and when it lose focus, the cell returns to the original value.

When i select the cell with tab and the arrow keys and then I directly start to type the new content, the error occurs. The cell still become un error state if I enter an existing value, but when the cell lose focus, the value isn't reverted. CancelEdit() is called, everything seems to work, but in the end, the property is set to the new erronous value.

I've joined an example project.