I donβt think that a normal DataBinding for a HeaderCheckBox is possible, because the CheckBox exists as part of the Template and it is in a different VisualTree branch than the DataGridItems
I usually do it the other way around: when the CheckBox header is checked, check the entire CheckBoxes line. My main reason for this is because CheckBoxes are usually there, so users can check / uncheck them, and if they are related to the status of the CheckBox header, the user cannot change them.
To implement this, I usually connect to the Click or Checked event in the CheckBox header.
If the state of the CheckBox.IsChecked line is tied to something in the ViewModel, I will connect this event to Command in my ViewModel and set the data item to which CheckBox.IsChecked bound to true / false depending on the state of the CheckBox header (usually passed as CommandParameter )
If the status of CheckBox.IsChecked not tied to anything, you can use the usual code to scroll through your DataGrid.Items , use ItemContainerGenerator to get the ItemContainer for each item, find the CheckBox and then set its check state.
source share