reference from-
http://stackoverflow.com/questions/10225860/unchecked-any-one-checkbox-of-celltemplate-from-the-list-i-want-to-uncheck-the
solution-
Here is the control template for the header
<Style x:Key="checkBoxHeaderStyle"
TargetType="{x:Type w:DataGridColumnHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type w:DataGridColumnHeader}">
<CheckBox
IsChecked="{Binding Path = IsSelectAllChecked , Mode = TwoWay}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Here is the template column applying the style
<w:DataGridTemplateColumn MinWidth="50"
HeaderStyle="{DynamicResource checkBoxHeaderStyle}"
CanUserResize="False">
<w:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox Name="selectAllCheckBox"
HorizontalAlignment="Center" Margin="1,0,0,0" VerticalAlignment="Center"
IsChecked="{Binding Path = IsSelected, Mode=TwoWay}" />
</DataTemplate>
</w:DataGridTemplateColumn.CellTemplate>
</w:DataGridTemplateColumn>
The is selected property is
public bool IsSelected
{
get { return selected; }
set { selected = value;
OnPropertyChanged("IsSelected");
}
}
For the header check box
public bool IsSelectAllChecked
{
get { return isSelectAllChecked; }
set
{
isSelectAllChecked = value;
base.OnPropertyChanged("IsSelectAllChecked");
//Call the method which sets the IsSelected property to true of false, based on value
SetAllCheckBoxesState(value);
}
}
Hope this will help you.