Skip to main content

CalculateDistanceFromAncestor Method

Calculates the distance from a visual's ancestor.

Definition

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

public static int CalculateDistanceFromAncestor(
this Visual visual,
Visual? ancestor
)

Parameters

  Visual
The visual.
  Visual
The ancestor visual.

Return Value

Int32
The number of steps from the visual to the ancestor or -1 if visual is not a descendent of ancestor.

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
Avalonia.VisualTree Namespace