/// <summary> /// Gets the parent popup of the given element or null if it is not contained in a popup. /// </summary> public static Popup GetParentPopup(FrameworkElement element) { return element.GetVisualAncestors().LastOrDefault() as Popup; }