Class
ElementTreeHelper

Exposes helper methods for searching and traversing visual trees.

Definition

Namespace:Telerik.Core

Assembly:Telerik.WinUI.Controls.dll

Syntax:

cs-api-definition
public static class ElementTreeHelper

Inheritance: objectElementTreeHelper

Methods

EnumVisualDescendants(DependencyObject, Predicate<DependencyObject>, TreeTraversalMode)

Returns a lazily evaluated iterator that allows linear iteration over a tree of DependencyObjects.

Declaration

cs-api-definition
public static IEnumerable<DependencyObject> EnumVisualDescendants(DependencyObject parent, Predicate<DependencyObject> condition = null, TreeTraversalMode mode = TreeTraversalMode.BreadthFirst)

Parameters

parent

DependencyObject

The root element of the tree to iterate over.

condition

Predicate<DependencyObject>

A predicate to filter what elements are returned.

mode

TreeTraversalMode

The tree traversal mode of the iteration algorithm.

Returns

IEnumerable<DependencyObject>

A lazily evaluated iterator that allows linear iteration over a tree of DependencyObjects.

FindLastVisualAncestor<T>(DependencyObject, Predicate<DependencyObject>)

Finds the last visual ancestor of the provided type.

Declaration

cs-api-definition
public static T FindLastVisualAncestor<T>(DependencyObject child, Predicate<DependencyObject> condition = null) where T : class

Parameters

child

DependencyObject

The from which to start the search.

condition

Predicate<DependencyObject>

A condition to test each ancestor of the T type.

Returns

T

The last ancestor of the specified T type which matches the condition.

FindVisualAncestor<T>(DependencyObject, Predicate<DependencyObject>)

Finds a visual ancestor from a given type and based on a given condition that is in the parent chain of a given child element.

Declaration

cs-api-definition
public static T FindVisualAncestor<T>(DependencyObject child, Predicate<DependencyObject> condition = null) where T : class

Parameters

child

DependencyObject

The child.

condition

Predicate<DependencyObject>

The condition.

Returns

T

An instance of the given type if found, otherwise null.

FindVisualDescendant<T>(DependencyObject, Predicate<DependencyObject>)

Finds a visual descendant from a given type and based on a given condition that is in the hierarchy of a given parent element.

Declaration

cs-api-definition
public static T FindVisualDescendant<T>(DependencyObject parent, Predicate<DependencyObject> condition = null) where T : class

Parameters

parent

DependencyObject

The parent.

condition

Predicate<DependencyObject>

The condition.

Returns

T

An instance of the given type if found, otherwise null.

IsElementRendered(FrameworkElement)

Determines whether the specified element is rendered on the visual tree.

Declaration

cs-api-definition
public static bool IsElementRendered(FrameworkElement element)

Parameters

element

FrameworkElement

Returns

bool

IsParentChainHitTestVisible(UIElement)

Determines whether all the ancestors of the specified UIElement instance are hit-test visible.

Declaration

cs-api-definition
public static bool IsParentChainHitTestVisible(UIElement element)

Parameters

element

UIElement

The element to start from.

Returns

bool

True if all the ancestors are hit-test visible, false otherwise.

SafeTransformBounds(FrameworkElement, FrameworkElement, Rect)

Transforms the specified rect using the TransformToVisual routine while checking for valid transform conditions - e.g. elements are both loaded and rendered.

Declaration

cs-api-definition
public static Rect SafeTransformBounds(FrameworkElement from, FrameworkElement to, Rect bounds)

Parameters

from

FrameworkElement

From.

to

FrameworkElement

To.

bounds

Rect

The bounds.

Returns

Rect

SafeTransformPoint(FrameworkElement, FrameworkElement, Point)

Transforms the specified point using the TransformToVisual routine while checking for valid transform conditions - e.g. elements are both loaded and rendered.

Declaration

cs-api-definition
public static Point SafeTransformPoint(FrameworkElement from, FrameworkElement to, Point point)

Parameters

from

FrameworkElement

From.

to

FrameworkElement

To.

point

Point

The transform point.

Returns

Point

TransformRectForFlowDirection(Rect, FlowDirection)

Transforms a rectangle according to the provided float direction. Since a struct has its origin always at the top left point, to make a usable in a RightToLeft scenario we need to offset its X coordinate with its width.

Declaration

cs-api-definition
public static Rect TransformRectForFlowDirection(Rect source, FlowDirection direction)

Parameters

source

Rect

The source rectangle to transform.

direction

FlowDirection

The flow direction to transform against.

Returns

Rect

The transformed rectangle.