private void OnChildRemoved(TreeGridElement child) { // Clear the model for the child child.SetModel(null); // Notify the model that a child was removed from the item Model?.OnChildRemoved(child); }
private void OnChildReplaced(TreeGridElement oldChild, object item, int index) { // Verify the new child TreeGridElement child = VerifyItem(item); // Clear the model for the old child oldChild.SetModel(null); // Notify the model that a child was replaced Model?.OnChildReplaced(oldChild, child, index); }
private void OnChildAdded(object item) { // Verify the new child TreeGridElement child = VerifyItem(item); // Set the model for the child child.SetModel(Model, this); // Notify the model that a child was added to the item Model?.OnChildAdded(child); }
internal void SetModel(TreeGridModel NewModel, TreeGridElement NewParent = null) { // Set the element information Model = NewModel; Parent = NewParent; Level = (NewParent != null) ? NewParent.Level + 1 : 0; // Iterate through all child elements foreach (TreeGridElement Child in Children) { // Set the model for the child Child.SetModel(NewModel, this); } }
private static void OnIsExpandedChanged(DependencyObject element, DependencyPropertyChangedEventArgs args) { // Get the tree item TreeGridElement item = (TreeGridElement)element; // Is the item being expanded? if ((bool)args.NewValue) { // Raise expanding event item.RaiseEvent(new RoutedEventArgs(ExpandingEvent, item)); // Execute derived expanding handler item.OnExpanding(); // Expand the item in the model item.Model?.Expand(item); // Raise expanded event item.RaiseEvent(new RoutedEventArgs(ExpandedEvent, item)); // Execute derived expanded handler item.OnExpanded(); } else { // Raise collapsing event item.RaiseEvent(new RoutedEventArgs(CollapsingEvent, item)); // Execute derived collapsing handler item.OnCollapsing(); // Collapse the item in the model item.Model?.Collapse(item); // Raise collapsed event item.RaiseEvent(new RoutedEventArgs(CollapsedEvent, item)); // Execute derived collapsed handler item.OnCollapsed(); } }