I'm trying to swap out a WPF datagrid to a xceed\Extended WPF Toolkit DataGridControl.
I need to react to the click event in a checkbox column ... to summarizing a number of other columns.
In the existing datagrid I have a checkbox column, that is bound to a Observable Collection and I call a method if any check box is checked\unchecked. The xaml I use for this, which works, is as such:
<DataGridTemplateColumn Width="40" Header="Inc">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox
IsChecked="{Binding Include ,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Checked="CheckBoxUpdated" Unchecked="CheckBoxUpdated" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
For the xceed datagridcontrol I started with the simple syntax below, and the the initial binding seemed OK, but I don't have a click event to respond to:
<xcdg:Column FieldName="Include" Title="Inc" />
Now I tried to do something similar to the original code using the xceed datagridcontrol, as such:
<xcdg:Column FieldName="Include" Title="Inc" Width="*" >
<xcdg:Column.CellContentTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Include ,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Click="CheckBoxUpdated"/>
</DataTemplate>
</xcdg:Column.CellContentTemplate>
But I don't think this is the correct syntax. It seems the binding is not working ... based on the initial values of the collection.
(note code behind sets this items source as such dg.ItemsSource = collectionView;)
Any ideas on how to setup a checkbox DataTemplate and the binding correctly?
Thanks
I just found a post at xceed forums that gave me the syntax I needed, that to set the FieldName=".", not FieldName="Include" . My guess is that having FieldName="Include" and the "{Binding Include ..." was confusing the binding.
<xcdg:Column FieldName="." Title="Inc" Width="*" >
<xcdg:Column.CellContentTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Include ,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Click="CheckBoxUpdated"/>
</DataTemplate>
</xcdg:Column.CellContentTemplate>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With