This example demonstrates how to add a CheckBox column which allows you to check/uncheck all CheckBoxes in this column.
To do this, we add a CheckEdit to the current column's header and bind its IsChecked property to the attached property. Then, we subscribe to the GridColumn's Loaded event.
When Loaded is raised, we iterate through all items in the ItemSource and subscribe to its PropertyChanged event. Also, we iterate through all cells in the current column. If the cell value equal true, we increase the total count of true values.
After that, we subscribe to the ItemSource collection's CollectionChanged event. When IsChecked is changed, we iterate through all cells of the column and set its value to the IsChecked value.
When CollectionChanged is raised, we calculate which item was added/deleted and subscribe/unsubscribe to its PropertyChanged event. Then, we calculate to what value CheckEdit must be set.
When PropertyChanged is raised, we increase/decrease the total count of true values and also determine to what value CheckEdi must be set.
To do this, we add a CheckEdit to the current column's header and bind its IsChecked property to the attached property. Then, we subscribe to the GridColumn's Loaded event.
When Loaded is raised, we iterate through all items in the ItemSource and subscribe to its PropertyChanged event. Also, we iterate through all cells in the current column. If the cell value equal true, we increase the total count of true values.
After that, we subscribe to the ItemSource collection's CollectionChanged event. When IsChecked is changed, we iterate through all cells of the column and set its value to the IsChecked value.
When CollectionChanged is raised, we calculate which item was added/deleted and subscribe/unsubscribe to its PropertyChanged event. Then, we calculate to what value CheckEdit must be set.
When PropertyChanged is raised, we increase/decrease the total count of true values and also determine to what value CheckEdi must be set.