Skip to main content
A newer version of this page is available. .

LayoutTreeHelper Class

A helper that can search for nodes in an application’s visual and logical trees.

Namespace: DevExpress.WinUI.Core

Assembly: DevExpress.WinUI.Core.v22.1.dll

NuGet Package: DevExpress.WinUI

Declaration

public static class LayoutTreeHelper

Remarks

Retrieve an Object’s Visual Parents

Call the GetVisualParents(DependencyObject, DependencyObject) method to search for visual parents of an object that is placed in a visual or logical tree.

public static IEnumerable<DependencyObject> GetVisualParents(
    DependencyObject child, 
    DependencyObject stopNode = null
)

This function returns a LINQ compatible collection. It allows you to use LINQ methods to access nodes of the visual and logical trees.

For example, the following code sample obtains a specific parent Grid:

var obj  = LayoutTreeHelper.GetVisualParents(PART_Button as DependencyObject)
    .OfType<Grid>()
    .FirstOrDefault(x => x.Name == "PART_Grid");

Retrieve an Object’s Visual Children

Call the GetVisualChildren(DependencyObject) method to search for visual children of an object that is placed in a visual tree.

To access the visual children of an object, you can use the LayoutTreeHelper.GetVisualChildren function.

public static IEnumerable<DependencyObject> GetVisualChildren(DependencyObject parent)

Similar to GetVisualParents, this function also returns a LINQ compatible collection. Thus, you can also use LINQ extension methods to obtain the required child nodes.

The code sample below obtains the child CheckBox named PART_CheckBox by using the GetVisualChildren function.

var obj = LayoutTreeHelper.GetVisualChildren(PART_Grid as DependencyObject)
    .OfType<CheckBox>()
    .FirstOrDefault(x => x.Name == "PART_CheckBox");

Inheritance

Object
LayoutTreeHelper
See Also