menu

UWP

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class VisualTreeExtensions - UWP API Reference | Syncfusion

    Show / Hide Table of Contents

    Class VisualTreeExtensions

    Represents a class that provides various helper methods used to find the child and parent of visual object from visual tree.

    Inheritance
    System.Object
    VisualTreeExtensions
    Namespace: Syncfusion.UI.Xaml.Controls.Primitives
    Assembly: Syncfusion.SfMenu.UWP.dll
    Syntax
    [ClassReference(IsReviewed = false)]
    public static class VisualTreeExtensions : Object
    Remarks

    Since many of these extension methods are declared on types like DependencyObject high up in the class hierarchy, we've placed them in the Primitives namespace which is less likely to be imported for normal scenarios.

    Methods

    GetBoundsRelativeTo(FrameworkElement, UIElement)

    Returns the size of an UI element and its position relative to another framework element.

    Declaration
    public static Nullable<Rect> GetBoundsRelativeTo(this FrameworkElement element, UIElement otherElement)
    Parameters
    Type Name Description
    Windows.UI.Xaml.FrameworkElement element

    The element.

    Windows.UI.Xaml.UIElement otherElement

    The element relative to the other element.

    Returns
    Type Description
    System.Nullable<Windows.Foundation.Rect>

    The bounds of the element relative to another element, or null if the elements are not related.

    Exceptions
    Type Condition
    System.ArgumentNullException

    element is null.

    System.ArgumentNullException

    otherElement is null.

    GetVisualAncestors(DependencyObject)

    Helps to find the ancestor elements of the provided visual object by searching in visual tree.

    Declaration
    public static IEnumerable<DependencyObject> GetVisualAncestors(this DependencyObject element)
    Parameters
    Type Name Description
    Windows.UI.Xaml.DependencyObject element

    The element.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Windows.UI.Xaml.DependencyObject>

    The visual tree ancestors of the element.

    Exceptions
    Type Condition
    System.ArgumentNullException

    element is null.

    GetVisualAncestorsAndSelf(DependencyObject)

    Helps to find the ancestor of a given element in the visual tree or find the object itself if it matches.

    Declaration
    public static IEnumerable<DependencyObject> GetVisualAncestorsAndSelf(this DependencyObject element)
    Parameters
    Type Name Description
    Windows.UI.Xaml.DependencyObject element

    The element.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Windows.UI.Xaml.DependencyObject>

    The visual tree ancestors of an element and the element itself.

    Exceptions
    Type Condition
    System.ArgumentNullException

    element is null.

    GetVisualChildren(DependencyObject)

    Helps to iterate and return a collection of visual children from the object in visual tree.

    Declaration
    public static IEnumerable<DependencyObject> GetVisualChildren(this DependencyObject element)
    Parameters
    Type Name Description
    Windows.UI.Xaml.DependencyObject element

    The element.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Windows.UI.Xaml.DependencyObject>

    The visual tree children of an element.

    Exceptions
    Type Condition
    System.ArgumentNullException

    element is null.

    GetVisualChildrenAndSelf(DependencyObject)

    Helps to find the visual children of a given element in the visual tree or find the object itself if it matches.

    Declaration
    public static IEnumerable<DependencyObject> GetVisualChildrenAndSelf(this DependencyObject element)
    Parameters
    Type Name Description
    Windows.UI.Xaml.DependencyObject element

    The element.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Windows.UI.Xaml.DependencyObject>

    The visual tree children of an element and the element itself.

    Exceptions
    Type Condition
    System.ArgumentNullException

    element is null.

    GetVisualDescendants(DependencyObject)

    Helps to find the child elements of the provided visual object by searching in visual tree.

    Declaration
    public static IEnumerable<DependencyObject> GetVisualDescendants(this DependencyObject element)
    Parameters
    Type Name Description
    Windows.UI.Xaml.DependencyObject element

    The element.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Windows.UI.Xaml.DependencyObject>

    The visual tree descendants of an element.

    Exceptions
    Type Condition
    System.ArgumentNullException

    element is null.

    GetVisualDescendantsAndSelf(DependencyObject)

    Get the visual tree descendants of an element and the element itself.

    Declaration
    public static IEnumerable<DependencyObject> GetVisualDescendantsAndSelf(this DependencyObject element)
    Parameters
    Type Name Description
    Windows.UI.Xaml.DependencyObject element

    The element.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Windows.UI.Xaml.DependencyObject>

    The visual tree descendants of an element and the element itself.

    Exceptions
    Type Condition
    System.ArgumentNullException

    element is null.

    GetVisualSiblings(DependencyObject)

    Helps to find the siblings of the provided element by searching in visual tree.

    Declaration
    public static IEnumerable<DependencyObject> GetVisualSiblings(this DependencyObject element)
    Parameters
    Type Name Description
    Windows.UI.Xaml.DependencyObject element

    The element.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Windows.UI.Xaml.DependencyObject>

    The visual tree siblings of an element.

    Exceptions
    Type Condition
    System.ArgumentNullException

    element is null.

    GetVisualSiblingsAndSelf(DependencyObject)

    Helps to find the siblings of a given element in the visual tree or find the object itself if it matches.

    Declaration
    public static IEnumerable<DependencyObject> GetVisualSiblingsAndSelf(this DependencyObject element)
    Parameters
    Type Name Description
    Windows.UI.Xaml.DependencyObject element

    The element.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Windows.UI.Xaml.DependencyObject>

    The visual tree siblings of an element and the element itself.

    Exceptions
    Type Condition
    System.ArgumentNullException

    element is null.

    InvokeOnLayoutUpdated(FrameworkElement, Action)

    Occurs when the layout of the visual tree changes due to its relative properties value changes or when any other action is performed.

    Declaration
    public static void InvokeOnLayoutUpdated(this FrameworkElement element, Action action)
    Parameters
    Type Name Description
    Windows.UI.Xaml.FrameworkElement element

    The element.

    System.Action action

    The action to perform.

    Exceptions
    Type Condition
    System.ArgumentNullException

    element is null.

    System.ArgumentNullException

    action is null.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved