ExtensionMethods::FindAncestor<TAncestorType> Method (Visual^)

 

Finds the first ancestor of a given type in the logical or visual tree.

Namespace:   Microsoft.VisualStudio.PlatformUI
Assembly:  Microsoft.VisualStudio.Utilities (in Microsoft.VisualStudio.Utilities.dll)

public:
generic<typename TAncestorType>
where TAncestorType : DependencyObject
[ExtensionAttribute]
static TAncestorType FindAncestor(
	Visual^ obj
)

Parameters

obj
Type: System.Windows.Media::Visual^

The object at which to begin searching.

Return Value

Type: TAncestorType

The first ancestor of type T in the parent chain of obj, or null if no ancestor is found

Type Parameters

TAncestorType

The type of ancestor to find.

The type of obj is the Visual rather than the DependencyObject in order to disambiguate this method from FindAncestor(ViewElement element). If you need to find an ancestor of a non-Visual DependencyObject you should call FindAncestor<TAncestorType, DependencyObject>(obj, GetVisualOrLogicalParent) directly.

Return to top
Show: