In WPF datagrid
,When a cell is invalid,it prevents the the other cells editing so user can not enter data until the invalid cell comes valid.I was wonder if there is a way to disable this behavior?
There is how i use datagrid
:
<DataGrid ItemsSource="{Binding ..}">
<DataGrid.Columns>
<DataGridTextColumn Header="Name"
Binding="{Binding Name
, UpdateSourceTrigger=PropertyChanged
, NotifyOnValidationError=True
, ValidatesOnDataErrors=True
, ValidatesOnExceptions=True}"
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
I overrided the OnCanExecuteBeginEdit method of the
datagrid
like below and it works now.the same question:DataGrid: On cell validation error other row cells are uneditable/Readonly
If it is an mvvm application and this behavior will repeat multiple times in your application, you can create your own
DataGrid
that inherits fromDataGrid
, and override theOnCellEditEnding
method like this:If not, you can do the same by registrating to the
CellEditEnding
event of your grid, something like this: