public void Clear(UIElement parent) { //clear all child //and remove parent linkage for (int i = _list.Count - 1; i >= 0; --i) { UIElement ui = _list[i]; ui.ParentUI = null; UIElement.UnsafeRemoveLinkedNode(ui); } _list.Clear(); if (parent.CurrentPrimaryRenderElement is IContainerRenderElement container) { container.ClearAllChildren(); parent.CurrentPrimaryRenderElement.InvalidateGraphics(); } parent.InvalidateLayout(); }
public void Clear(UIElement parent) { LinkedListNode <T> node = _linkedList.First; while (node != null) { UIElement ui = node.Value; node = node.Next; ui.ParentUI = null; UIElement.UnsafeRemoveLinkedNode(ui); } _linkedList.Clear(); //-------- //need to remove presentation parent._needContentLayout = true; if (parent.CurrentPrimaryRenderElement is IContainerRenderElement parentBox) { parentBox.ClearAllChildren(); } }