TreeHelper Class

Summary

Helper methods for UI-related tasks. This class was obtained from Philip Sumi (a fellow WPF Disciples blog) http://www.hardcodet.net/uploads/2009/06/UIHelper.cs
Namespace
MahApps.Metro.Controls
Base Types
  • object
graph BT Type-->Base0["object"] Type["TreeHelper"] class Type type-node

Syntax

public static class TreeHelper

Methods

Name Value Summary
FindChild<T>(DependencyObject, string) T
Finds a Child of a given item in the visual tree.
static
FindChildren<T>(DependencyObject, bool) IEnumerable<T>
Analyzes both visual and logical tree in order to find all elements of a given type that are descendants of the source item.
static
GetAncestors(DependencyObject) IEnumerable<DependencyObject>
Finds all Ancestors of a given item on the visual tree.
static
GetChildObjects(DependencyObject, bool) IEnumerable<DependencyObject>
This method is an alternative to WPF's VisualTreeHelper.GetChild method, which also supports content elements. Keep in mind that for content elements, this method falls back to the logical tree of the element.
static
GetParentObject(DependencyObject) DependencyObject
This method is an alternative to WPF's VisualTreeHelper.GetParent method, which also supports content elements. Keep in mind that for content element, this method falls back to the logical tree of the element!
static
GetVisualAncestor<T>(DependencyObject?) T
Tries to find and returns a visual ancestor, starting at the leaf.

If element is not of Visual or Visual3D the logical ancestry is used.

static
GetVisualAncestry(DependencyObject?) IEnumerable<DependencyObject>
Returns full visual ancestry, starting at the leaf.

If element is not of Visual or Visual3D the logical ancestry is used.

static
IsDescendantOf(DependencyObject, DependencyObject) bool
static
TryFindFromPoint<T>(UIElement, Point) T
Tries to locate a given item within the visual tree, starting with the dependency object at a given position.
static
TryFindParent<T>(DependencyObject) T
Finds a parent of a given item on the visual tree.
static