private static void OnIsCheckedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { CheckTreeViewItem collapsed = d as CheckTreeViewItem; if (collapsed != null) { collapsed.OnIsCheckCheckedChanged(e.OldValue, e.NewValue); } }
private void UpdateAllChildrenStatus(CheckTreeViewItem node) { var lstVisualChildren = GetFirstVisualChildren <CheckTreeViewItem>(node); if (lstVisualChildren != null && lstVisualChildren.Count > 0) { foreach (var item in lstVisualChildren) { if (item.IsEnabled) { item.IsChecked = node.IsChecked; UpdateAllChildrenStatus(item); } } } }
internal void NotifyPropertyChanged(object sender, string args) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(args)); } if (sender is CheckTreeViewItem) { CheckTreeViewItem child = sender as CheckTreeViewItem; if (args.CompareTo(_indeterminateState) == 0 && child.Parent is CheckTreeViewItem) { CheckTreeViewItem parent = child.Parent as CheckTreeViewItem; SetCheckBoxState(parent, CheckBoxState.Indeterminate); //recursive call to update all its parents to indeterminate } } }
void SetCheckBoxState(CheckTreeViewItem item, CheckBoxState state) { switch (state) { case CheckBoxState.IsChecked: item.IsChecked = true; // item.NotifyPropertyChanged(item, _isCheckedState); break; case CheckBoxState.Indeterminate: item.IsChecked = null; //item.NotifyPropertyChanged(item, _indeterminateState); break; case CheckBoxState.Unchecked: item.IsChecked = false; //item.NotifyPropertyChanged(item, _uncheckedState); break; } }