10
I have a datagrid whose one of the header column is Three-state checkbox. The celltemplate for that column contains two state checkbox + AllItems CheckBox - Item1 - Item2 - Item3 .. I wanted to use AllItems checkbox to select/unselect all items (item1,item2) which works fine. Next I wanted to set AllItems checkbox to intermediate state when not all items are selected/unselected. Similarly I wanted to set AllItems checkbox as checked/unchecked when all items get manually selected.
Here is the code that I tried...
<dg:DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<StackPanel x:Name="StackPanelForItemCheckbox" Orientation="Horizontal">
<CheckBox x:Name="AllItemSelectionCheckBox" HorizontalAlignment="Left" Cursor="Hand"
IsChecked="{Binding IsAllItemChecked, Mode=TwoWay}"
IsThreeState="True" Checked="ItemSelectionCheckBox_Checked"
Unchecked="ItemSelectionCheckBox_Unchecked"
Click="AllItemSelectionCheckBox_Click">
<TextBlock x:Name="ItemNameTextBlock" Text="Item" Margin="10,0,0,0">
......
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate x:Name="ItemCheckDataTemplate">
<StackPanel x:Name="ItemCheckBoxStackPanel" Orientation="Horizontal">
<CheckBox x:Name="itemCheckBox" Cursor="Hand" IsChecked="{Binding IsItemChecked, Mode=TwoWay}" Click="ItemSelectionCheckBox_Click"></CheckBox>
<TextBlock x:Name="ItemNameTextBlock" Text="{Binding Path=Item}"> </TextBlock>
</StackPanel>
</DataTemplate>
...
"ItemSelectionCheckBox_Click" method looks for all three state (all-checked, none-ch