Direct Binding DataGridCheckBoxColumn

I am using the WPF Toolkit Datagrid and has one column, which is a DataGridCheckBoxColumn bound to the bool property on my ViewModel.

My problem is that I do not want the property to immediately update the value when the user checks or unchecks the box.

Now you need to go from the cell to update the property. This is a checkbox. It cannot be in the middle of editing, like a text field ...

Any help would be appreciated.

/ J

+7
checkbox wpf datagrid
source share
3 answers

You must set the UpdateSourceTrigger property to bind to PropertyChanged. By default, the LostFocus function is used.

+21
source share

The solution is to NOT use a DataGridCheckBoxColumn for this. Use instead

<dg:DataGridTemplateColumn Width="20" Header="" SortMemberPath="IsSelected"> <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <CheckBox IsChecked="{Binding Path=IsSelected}" /> </DataTemplate> </dg:DataGridTemplateColumn.CellTemplate> </dg:DataGridTemplateColumn> 

which by default has its own UpdateSourcerigger for PropertyChanged ...

DataGridCheckBoxColumn has an UpdateSourceTrigger value of Explicit and cannot be changed. More details here: http://blogs.msdn.com/vinsibal/archive/2009/04/07/5-random-gotchas-with-the-wpf-datagrid.aspx

+9
source share
0
source share

All Articles