Data change tracking like in DataGridView CurrentCellDirtyStateChanged?

Jun 19, 2009 at 11:24 AM

My scenario:

I'm use MVVM pattern. I'm have DataGridCheckBoxColumn. I need that at least one cell must be checked. My column:


<wpftk:DataGridCheckBoxColumn Header="Some text"
Binding="{Binding Path=IsDefault, UpdateSourceTrigger=PropertyChanged}"
CellStyle="{StaticResource SingleClickEditing}"

My ViewModel need to know when Cell is checked or unchecked immideately, when user click on it. Not then focus leave cell or rise CellEndEdit event. In WinForms I can listen CurrentCellDirtyStateChanged

event and do my work, but here I'm not found any way to do that. UpdateSourceTrigger=PropertyChanged don't work. Any ideas for this?


Jun 20, 2009 at 12:53 PM

Well. I think this is a bug or somethig... Because when I'm replace DataGridCheckBoxColumn with DataGridTemplateColumn with CheckBox, UpdateSourceTrigger start work properly:


<wpftk:DataGridTemplateColumn Header="Some text"
CellStyle="{StaticResource SingleClickEditing}"
            <CheckBox IsChecked="{Binding Path=IsDefault, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

Now, my IsDefault property receive new values when IsChecked property is changed.


Jun 23, 2009 at 5:16 AM

This is by design.  With DataGridTemplateColumn, you manage the data bindings yourself whereas the other stock columns will manage the data binding updates for you.  This is so the transaction scenario works when editing cells and rows.  Notice with DataGridTemplateColumn you don't get cell cancel functionality right out of the box.