Table of Contents

Class LogicalExtensions

Namespace
Avalonia.LogicalTree
Assembly
Avalonia.Base.dll

Provides extension methods for working with the logical tree.

public static class LogicalExtensions
Inheritance
LogicalExtensions
Inherited Members

Methods

FindLogicalAncestorOfType<T>(ILogical?, bool)

Finds first ancestor of given type.

public static T? FindLogicalAncestorOfType<T>(this ILogical? logical, bool includeSelf = false) where T : class

Parameters

logical ILogical

The logical.

includeSelf bool

If given logical should be included in search.

Returns

T

First ancestor of given type.

Type Parameters

T

Ancestor type.

FindLogicalDescendantOfType<T>(ILogical?, bool)

Finds first descendant of given type.

public static T? FindLogicalDescendantOfType<T>(this ILogical? logical, bool includeSelf = false) where T : class

Parameters

logical ILogical

The logical.

includeSelf bool

If given logical should be included in search.

Returns

T

First descendant of given type.

Type Parameters

T

Descendant type.

GetLogicalAncestors(ILogical)

Enumerates the ancestors of an ILogical in the logical tree.

public static IEnumerable<ILogical> GetLogicalAncestors(this ILogical logical)

Parameters

logical ILogical

The logical.

Returns

IEnumerable<ILogical>

The logical's ancestors.

GetLogicalChildren(ILogical)

Enumerates the children of an ILogical in the logical tree.

public static IEnumerable<ILogical> GetLogicalChildren(this ILogical logical)

Parameters

logical ILogical

The logical.

Returns

IEnumerable<ILogical>

The logical children.

GetLogicalDescendants(ILogical)

Enumerates the descendants of an ILogical in the logical tree.

public static IEnumerable<ILogical> GetLogicalDescendants(this ILogical logical)

Parameters

logical ILogical

The logical.

Returns

IEnumerable<ILogical>

The logical's ancestors.

GetLogicalParent(ILogical)

Gets the logical parent of an ILogical.

public static ILogical? GetLogicalParent(this ILogical logical)

Parameters

logical ILogical

The logical.

Returns

ILogical

The parent, or null if the logical is unparented.

GetLogicalParent<T>(ILogical)

Gets the logical parent of an ILogical.

public static T? GetLogicalParent<T>(this ILogical logical) where T : class

Parameters

logical ILogical

The logical.

Returns

T

The parent, or null if the logical is unparented or its parent is not of type T.

Type Parameters

T

The type of the logical parent.

GetLogicalSiblings(ILogical)

Enumerates the siblings of an ILogical in the logical tree.

public static IEnumerable<ILogical> GetLogicalSiblings(this ILogical logical)

Parameters

logical ILogical

The logical.

Returns

IEnumerable<ILogical>

The logical siblings.

GetSelfAndLogicalAncestors(ILogical)

Enumerates an ILogical and its ancestors in the logical tree.

public static IEnumerable<ILogical> GetSelfAndLogicalAncestors(this ILogical logical)

Parameters

logical ILogical

The logical.

Returns

IEnumerable<ILogical>

The logical and its ancestors.

GetSelfAndLogicalDescendants(ILogical)

Enumerates an ILogical and its descendants in the logical tree.

public static IEnumerable<ILogical> GetSelfAndLogicalDescendants(this ILogical logical)

Parameters

logical ILogical

The logical.

Returns

IEnumerable<ILogical>

The logical and its ancestors.

IsLogicalAncestorOf(ILogical?, ILogical?)

Tests whether an ILogical is an ancestor of another logical.

public static bool IsLogicalAncestorOf(this ILogical? logical, ILogical? target)

Parameters

logical ILogical

The logical.

target ILogical

The potential descendant.

Returns

bool

True if logical is an ancestor of target; otherwise false.