Exemplo n.º 1
0
 public void RemoveChild(ServerTreeItemViewModel child)
 {
     if (Children.Contains(child))
     {
         child.Parent = null;
         Children.Remove(child);
     }
 }
Exemplo n.º 2
0
 public void AddChild(ServerTreeItemViewModel child)
 {
     if (!Children.Contains(child))
     {
         child.Parent = this;
         Children.Add(child);
     }
 }
Exemplo n.º 3
0
 private void OnChildrenChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     // Note: This section does not account for multiple items being involved in change operations.
     // Note: This section does not account for the replace operation.
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         ServerTreeItemViewModel child = (ServerTreeItemViewModel)e.NewItems[0];
         child.Parent = this;
     }
     else if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         ServerTreeItemViewModel child = (ServerTreeItemViewModel)e.OldItems[0];
         if (child.Parent == this)
         {
             child.Parent = null;
         }
     }
 }