ExtensionMethods.FindAncestor<TAncestorType> Method (Visual)
Visual Studio 2015
Finds the first ancestor of a given type in the logical or visual tree.
Assembly: Microsoft.VisualStudio.Utilities (in Microsoft.VisualStudio.Utilities.dll)
public static TAncestorType FindAncestor<TAncestorType>( this Visual obj ) where TAncestorType : DependencyObject
Parameters
- obj
-
Type:
System.Windows.Media.Visual
The object at which to begin searching.
Return Value
Type: TAncestorTypeThe 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.
Show: