Datagrid Column header should check / uncheck CheckBox’s state depending upon whether all CheckBoxes of a DataGridView column are checked or unchecked

//this event is for **Checked and UnChecked** of up check box (cbxall)
private void UpCheckbox_Checked(object sender, RoutedEventArgs e)
{
    //checkBox1 = cbxall (your up checkbox)
    if (checkBox1.IsChecked == true)
    {
        dataGrid1.Items.OfType<YourClass>().ToList().ForEach(x => x.IsChecked = true);
    }
    else
    {
        dataGrid1.Items.OfType<YourClass>().ToList().ForEach(x => x.IsChecked = false);
    }
}

//this event is for all other check box
//**Checked and UnChecked** of all other check box is this event
private void OtherCheckbox_Checked(object sender, RoutedEventArgs e)
{
    //checkBox1 = cbxall (your up checkbox)
    if (dataGrid1.Items.OfType<YourClass>().All(x => x.IsChecked == true))
    {
        checkBox1.IsChecked = true;
    }
    else if (dataGrid1.Items.OfType<YourClass>().All(x => x.IsChecked == false))
    {
        checkBox1.IsChecked = false;
    }
    else
    {
        checkBox1.IsChecked = null;
    }
}