Code I was using before...
Binding binding_isChecked = new Binding("IsChecked");Code I'm using now...
binding_isChecked.ElementName = "cbCheckAll";
binding_isChecked.Mode = BindingMode.OneWay;
DependencyProperty property_isChecked = CheckBox.IsCheckedProperty;
Binding binding_isNotChecked = new Binding("IsChecked");
binding_isNotChecked.ElementName = "cbCheckAll";
binding_isNotChecked.Mode = BindingMode.OneWay;
BoolToOppositeBoolConverter boolConverter = new BoolToOppositeBoolConverter();
binding_isNotChecked.Converter = boolConverter;
DependencyProperty property_isEnabled = CheckBox.IsEnabledProperty;
cb.SetBinding(property_isChecked, binding_isChecked);
cb.SetBinding(property_isEnabled, binding_isNotChecked);
cb.Checked += delegate
{
foreach (CheckBox checkBoxInStackPanel in sp.Children)
{
if (!checkBoxInStackPanel.Content.Equals(cbCheckAllContent))
{
checkBoxInStackPanel.IsChecked = true;
checkBoxInStackPanel.IsEnabled = false;
}
}
};
cb.Unchecked += delegate
{
foreach (CheckBox checkBoxInStackPanel in sp.Children)
{
if (!checkBoxInStackPanel.Content.Equals(cbCheckAllContent))
{
checkBoxInStackPanel.IsChecked = false;
checkBoxInStackPanel.IsEnabled = true;
}
}
};