Skip to main content

FindAncestorOfType<T>(Visual, Boolean, Predicate<T>) Method

Finds first ancestor of given type that matches a predicate.

Definition​

Namespace: Avalonia.VisualTree
Assembly: Avalonia.Base (in Avalonia.Base.dll)

public static T FindAncestorOfType<T>(
this Visual? visual,
bool includeSelf,
Predicate<T>? predicate
)
where T : class

Parameters​

  Visual
The visual.
  Boolean
If given visual should be included in search.
  Predicate(T)
The predicate that the ancestor must match.

Type Parameters​

Ancestor type.

Return Value​

T
First ancestor of given type.

Usage Note​

In Visual Basic and C#, you can call this method as an instance method on any object of type Visual. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also​

Reference​

VisualExtensions Class
FindAncestorOfType Overload
Avalonia.VisualTree Namespace