New to Telerik UI for WPFStart a free 30-day trial

Contains extension methods for enumerating the parents of an element.

Definition

Namespace:Telerik.Windows.Controls

Assembly:Telerik.Windows.Controls.dll

Syntax:

C#
public static class ParentOfTypeExtensions

Inheritance: objectParentOfTypeExtensions

Methods

Enumerates through element's parents in the visual tree.

C#
public static IEnumerable<DependencyObject> GetParents(this DependencyObject element)
Parameters:elementDependencyObjectReturns:

IEnumerable<DependencyObject>

Searches up in the visual tree for parent element of the specified type.

C#
public static T GetVisualParent<T>(this DependencyObject element) where T : DependencyObject
Parameters:elementDependencyObject

The target DependencyObject which visual parents will be traversed.

Returns:

T

Visual parent of the specified type if there is any, otherwise null.

Determines whether the element is an ancestor of the descendant.

C#
public static bool IsAncestorOf(this DependencyObject element, DependencyObject descendant)
Parameters:elementDependencyObjectdescendantDependencyObjectReturns:

bool

true if the visual object is an ancestor of descendant; otherwise, false.

Gets the parent element from the visual tree by given type.

C#
public static T ParentOfType<T>(this DependencyObject element) where T : DependencyObject
Parameters:elementDependencyObjectReturns:

T