WPat datagrid - commits changes to the checkbox column as soon as the value changes

I have this little problem with datagrid.

In my grid, I have a checkbox column, which is the only editable column.

The behavior I'm looking for is that the datagrid updates the ith data source as soon as the status of the checkbox changes. Thus, the user checks / deselects the> base datatable checkbox, which is updated.

The default behavior seems to update the source when the line loses focus, requiring the user to press a key or click on some other control to save the changes.
How can I change this behavior?

I do not see any property for the datagrid that could do this, and no CheckChanged event for the DataGridCheckBoxColumn.

+6
source share
2 answers

The DataGrid itself sets the UpdateSourceTrigger for all columns (except template columns) as LostFocus, and this cannot be overridden. Therefore, you must use the template columns with the check box template.

EDIT: This is just one of a long list of dumb errors in DataGrid columns. More details are described here .

+4
source

To bind a column, the UpdateSourceTrigger property is UpdateSourceTrigger . Here is a quick example, you can use it and fill in the blanks:

 <DataGrid x:Name="someGrid"> <DataGrid.Columns> <DataGridCheckBoxColumn Binding="{Binding SomeProperty, UpdateSourceTrigger=PropertyChanged}" /> </DataGrid.Columns> </DataGrid> 
+11
source

Source: https://habr.com/ru/post/889840/


All Articles