public static void RemoveAllRecursive(this AdornerLayer adr, UIElement element) { try { Action <UIElement> recurse = null; recurse = ((Action <UIElement>) delegate(UIElement elem) { adr.RemoveAll(elem); if (elem is Panel) { foreach (UIElement e in ((Panel)elem).Children) { recurse(e); } } else if (elem is Decorator) { recurse(((Decorator)elem).Child); } else if (elem is ContentControl) { if (((ContentControl)elem).Content is UIElement) { recurse(((ContentControl)elem).Content as UIElement); } } }); recurse(element); } catch { } }