Sdílet prostřednictvím


ExtensionMethods.FindAncestorOrSelf Method

Definition

Overloads

FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)

Helper method that finds the first ancestor of a given Type in the logical or visual tree, or the object itself if it matches in type.

FindAncestorOrSelf<TAncestorType>(Visual)

Helper method that finds the first ancestor of a given Type in the logical or visual tree, or the object itself if it matches in type.

FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)

Helper method that finds the first ancestor in the logical or visual tree, or the object itself, that is accepted by the ancestor selector function.

FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)

Helper method that finds the first ancestor of a given Type in the logical or visual tree, or the object itself if it matches in type.

public:
generic <typename TAncestorType, typename TElementType>
 where TAncestorType : System::Windows::DependencyObject[System::Runtime::CompilerServices::Extension]
 static TAncestorType FindAncestorOrSelf(TElementType obj, Func<TElementType, TElementType> ^ parentEvaluator);
public static TAncestorType FindAncestorOrSelf<TAncestorType,TElementType> (this TElementType obj, Func<TElementType,TElementType> parentEvaluator) where TAncestorType : System.Windows.DependencyObject;
static member FindAncestorOrSelf : 'ElementType * Func<'ElementType, 'ElementType> -> 'AncestorType (requires 'AncestorType :> System.Windows.DependencyObject)
<Extension()>
Public Function FindAncestorOrSelf(Of TAncestorType As DependencyObject, TElementType As DependencyObject) (obj As TElementType, parentEvaluator As Func(Of TElementType, TElementType)) As TAncestorType

Type Parameters

TAncestorType

The type of ancestor to find.

TElementType

The base type of intermediate elements in the ancestor tree.

Parameters

obj
TElementType

The object at which to begin searching.

parentEvaluator
Func<TElementType,TElementType>

Returns

TAncestorType

The object itself, if it matches in type, else the first ancestor of type T in the parent chain of obj, or null if no ancestor is found.

Remarks

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

Applies to

FindAncestorOrSelf<TAncestorType>(Visual)

Helper method that finds the first ancestor of a given Type in the logical or visual tree, or the object itself if it matches in type.

public:
generic <typename TAncestorType>
 where TAncestorType : System::Windows::DependencyObject[System::Runtime::CompilerServices::Extension]
 static TAncestorType FindAncestorOrSelf(System::Windows::Media::Visual ^ obj);
public static TAncestorType FindAncestorOrSelf<TAncestorType> (this System.Windows.Media.Visual obj) where TAncestorType : System.Windows.DependencyObject;
static member FindAncestorOrSelf : System.Windows.Media.Visual -> 'AncestorType (requires 'AncestorType :> System.Windows.DependencyObject)
<Extension()>
Public Function FindAncestorOrSelf(Of TAncestorType As DependencyObject) (obj As Visual) As TAncestorType

Type Parameters

TAncestorType

The type of ancestor to find.

Parameters

obj
Visual

The object at which to begin searching.

Returns

TAncestorType

The object itself, if it matches in type, else the first ancestor of type T in the parent chain of obj, or null if no ancestor is found.

Remarks

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

Applies to

FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)

Helper method that finds the first ancestor in the logical or visual tree, or the object itself, that is accepted by the ancestor selector function.

public:
generic <typename TElementType>
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ FindAncestorOrSelf(TElementType obj, Func<TElementType, TElementType> ^ parentEvaluator, Func<TElementType, bool> ^ ancestorSelector);
public static object FindAncestorOrSelf<TElementType> (this TElementType obj, Func<TElementType,TElementType> parentEvaluator, Func<TElementType,bool> ancestorSelector);
static member FindAncestorOrSelf : 'ElementType * Func<'ElementType, 'ElementType> * Func<'ElementType, bool> -> obj
<Extension()>
Public Function FindAncestorOrSelf(Of TElementType) (obj As TElementType, parentEvaluator As Func(Of TElementType, TElementType), ancestorSelector As Func(Of TElementType, Boolean)) As Object

Type Parameters

TElementType

The base type of intermediate elements in the ancestor tree.

Parameters

obj
TElementType

The object at which to begin searching.

parentEvaluator
Func<TElementType,TElementType>

The method used to determine the parent of an element.

ancestorSelector
Func<TElementType,Boolean>

The method used to select an ancestor of interest.

Returns

The first ancestor in the parent chain of obj accepted by the the ancestor selector function, or null if no ancestor is found.

Applies to