I have created a data table which contains 4 columns, 3 are strings and another one is Boolean type.
i mapped the datatable(xmldatadocument) to the datagridview in wpf.
so the resulting looks text column and checkbox column in data grid.
And i added a checkbox header template to the chekbox column header.
I am able to perform uncheck all checkboxes in column when i\the header checkbox is unchecked.
I am also able to perform check all checkboxes in column when the header chekcbox is checked.but i am bit troubled in if one of checkbox in that column is unchecked i need to uncheck the header checkbox also..
Kindly help me to resolve this..
i’ve added the screenshot, XAML and Code below.

PS: using WPF datagrid.
<dg:DataGrid.Columns>
<dg:DataGridCheckBoxColumn Binding="{Binding Check}" Width="50" >
<dg:DataGridCheckBoxColumn.HeaderTemplate>
<DataTemplate x:Name="dtAllChkBx">
<CheckBox Name="cbxAll" Content="{x:Static properties:Resources.lblAll}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"></CheckBox>
</DataTemplate>
</dg:DataGridCheckBoxColumn.HeaderTemplate>
public static ObservableCollection<Lst> list = new ObservableCollection<Lst>();
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
for (int i = 0; i < list.Count; i++)
{
list[i].Check = true;
}
}
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
for (int i = 0; i < list.Count; i++)
{
list[i].Check = false;
}
}
public class Lst : ObservableCollection<Lst>
{
public bool Check { get; set; }
}
Here is the control template for the header
Here is the template column applying the style
The is selected property is
For the header check box
I hope it helps 🙂