/// <summary> /// Add a node to be a new child of this node at the specified index. /// </summary> /// <param name="index">The index at which to add the new child.</param> /// <param name="child">The new child to add to this node.</param> /// <remarks> /// If child was previously a child of another node, it is removed /// from that node first. /// </remarks> public virtual void AddChild(int index, PNode child) { PNode oldParent = child.Parent; if (oldParent != null) { oldParent.RemoveChild(child); } child.Parent = this; ChildrenReference.Insert(index, child); child.InvalidatePaint(); InvalidateFullBounds(); FirePropertyChangedEvent(PROPERTY_KEY_CHILDREN, PROPERTY_CODE_CHILDREN, null, children); }