Show / Hide Table of Contents

Class VisualTreeHelper

Provides utility methods that can used to traverse object relationships (along child object or parent object axes) in the visual tree.

Inheritance
System.Object
VisualTreeHelper
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: System.Windows.Media
Assembly: OpenSilver.dll
Syntax
public sealed class VisualTreeHelper

Methods

| Improve this Doc View Source

FindElementsInHostCoordinates(Point, UIElement)

Retrieves a set of objects that are located within a specified point of an object's coordinate space.

Declaration
public static IEnumerable<UIElement> FindElementsInHostCoordinates(Point intersectingPoint, UIElement subtree)
Parameters
Type Name Description
Point intersectingPoint

The point to use as the determination point.

UIElement subtree

The object to search within.

Returns
Type Description
System.Collections.Generic.IEnumerable<UIElement>

An enumerable set of UIElement objects that are determined to be located in the visual tree composition at the specified point and within the specified subtee.

| Improve this Doc View Source

FindElementsInHostCoordinates(Rect, UIElement)

Retrieves a set of objects that are located within a specified Rect of an object's coordinate space.

Declaration
[NotImplemented]
public static IEnumerable<UIElement> FindElementsInHostCoordinates(Rect intersectingRect, UIElement subtree)
Parameters
Type Name Description
Rect intersectingRect

The Rect to use as the determination area.

UIElement subtree

The object to search within.

Returns
Type Description
System.Collections.Generic.IEnumerable<UIElement>

An enumerable set of UIElement objects that are determined to be located in the visual tree composition at the specified point and within the specified subtee.

| Improve this Doc View Source

GetChild(DependencyObject, Int32)

Using the provided index, obtains a specific child object of the provided object by examining the visual tree. Please note that the current implementation does not guarantee that the index corresponds to the visual order of the controls.

Declaration
public static DependencyObject GetChild(DependencyObject reference, int childIndex)
Parameters
Type Name Description
DependencyObject reference

The object that holds the child collection.

System.Int32 childIndex

The index of the requested child object in the reference child collection. Please note that the current implementation does not guarantee that the index corresponds to the visual order of the controls.

Returns
Type Description
DependencyObject

The child object as referenced by childIndex.

| Improve this Doc View Source

GetChild(UIElement, Int32)

Declaration
public static DependencyObject GetChild(UIElement reference, int childIndex)
Parameters
Type Name Description
UIElement reference
System.Int32 childIndex
Returns
Type Description
DependencyObject
| Improve this Doc View Source

GetChildrenCount(DependencyObject)

Returns the number of children that exist in an object's child collection in the visual tree.

Declaration
public static int GetChildrenCount(DependencyObject reference)
Parameters
Type Name Description
DependencyObject reference

The source visual.

Returns
Type Description
System.Int32

The number of visual children for the provided source visual.

| Improve this Doc View Source

GetChildrenCount(UIElement)

Returns the number of children that exist in an object's child collection in the visual tree.

Declaration
public static int GetChildrenCount(UIElement reference)
Parameters
Type Name Description
UIElement reference

The source visual.

Returns
Type Description
System.Int32

The number of visual children for the provided source visual.

| Improve this Doc View Source

GetOpenPopups()

Gets all open Popup controls.

Declaration
public static List<Popup> GetOpenPopups()
Returns
Type Description
System.Collections.Generic.List<Popup>

A list of all open Popup controls.

| Improve this Doc View Source

GetOpenPopups(Window)

Gets all open Popup controls for the specified Window.

Declaration
public static List<Popup> GetOpenPopups(Window window)
Parameters
Type Name Description
Window window

The Window to get Popup for.

Returns
Type Description
System.Collections.Generic.List<Popup>

A list of all open Popup controls.

| Improve this Doc View Source

GetParent(DependencyObject)

Returns an object's parent object in the visual tree.

Declaration
public static DependencyObject GetParent(DependencyObject reference)
Parameters
Type Name Description
DependencyObject reference

The object for which to get the parent object.

Returns
Type Description
DependencyObject

The parent object of the reference object in the visual tree.

| Improve this Doc View Source

GetParent(IDependencyObject)

Returns an object's parent object in the visual tree.

Declaration
public static DependencyObject GetParent(IDependencyObject reference)
Parameters
Type Name Description
System.Windows.IDependencyObject reference

The object for which to get the parent object.

Returns
Type Description
DependencyObject

The parent object of the reference object in the visual tree.

| Improve this Doc View Source

GetParent(UIElement)

Returns an object's parent object in the visual tree.

Declaration
public static DependencyObject GetParent(UIElement reference)
Parameters
Type Name Description
UIElement reference

The object for which to get the parent object.

Returns
Type Description
DependencyObject

The parent object of the reference object in the visual tree.

| Improve this Doc View Source

GetRoot(DependencyObject)

Returns an object's root object in the visual tree.

Declaration
public static DependencyObject GetRoot(DependencyObject reference)
Parameters
Type Name Description
DependencyObject reference

The object to get the root object for.

Returns
Type Description
DependencyObject

The root object of the reference object in the visual tree.

  • Improve this Doc
  • View Source