/// <summary> /// Walks the visual tree to determine if the currently focused element is contained within /// a parent DependencyObject. The FocusManager's GetFocusedElement method is used to determine /// the currently focused element, which is updated synchronously. /// </summary> /// <param name="element">Parent DependencyObject</param> /// <param name="uiElement">Parent UIElement. Used to query the element's XamlRoot.</param> /// <returns>True if the currently focused element is within the visual tree of the parent</returns> internal static bool ContainsFocusedElement(this DependencyObject element, UIElement uiElement) { return((element == null) ? false : element.ContainsChild(GetFocusedElement(uiElement) as DependencyObject)); }
/// <summary> /// Walks the visual tree to determine if the currently focused element is contained within /// a parent DependencyObject. The FocusManager's GetFocusedElement method is used to determine /// the currently focused element, which is updated synchronously. /// </summary> /// <param name="element">Parent DependencyObject</param> /// <returns>True if the currently focused element is within the visual tree of the parent</returns> internal static bool ContainsFocusedElement(this DependencyObject element) { return((element == null) ? false : element.ContainsChild(FocusManager.GetFocusedElement() as DependencyObject)); }