public void ChangeParent(IAdaptiveView view, IAdaptiveView newParent) { if (view == _base) { throw new ArgumentException("Cannot change parent of Base adaptive view!"); } AdaptiveView viewToChange = view as AdaptiveView; AdaptiveView newParentView = newParent as AdaptiveView; if (viewToChange == null) { throw new ArgumentNullException("view"); } if (newParentView == null) { throw new ArgumentNullException("newParent"); } // Remove view from old parent AdaptiveView oldParentView = viewToChange.ParentView as AdaptiveView; if (oldParentView != null && oldParentView != newParentView) { oldParentView.RemoveChildView(viewToChange); } newParentView.AddChildView(viewToChange); _document.OnChangeAdaptiveViewParent(viewToChange, oldParentView); }
public void DeleteAdaptiveView(IAdaptiveView view) { if (view == _base) { throw new ArgumentException("Cannot delete Base adaptive view!"); } AdaptiveView viewToDelete = view as AdaptiveView; if (viewToDelete != null) { AdaptiveView parent = viewToDelete.ParentView as AdaptiveView; if (parent != null) { // Remove this view from parent parent.RemoveChildView(viewToDelete); // Add child view to new parent foreach (AdaptiveView childView in viewToDelete.ChildViews) { if (childView != null) { parent.AddChildView(childView); } } } // Remove this view from views _views.Remove(viewToDelete); _document.OnDeleteAdaptiveView(viewToDelete); } }