Table of Contents

Class ViewExtensions

Namespace
Xui.Core.UI
Assembly
Xui.Core.dll

Provides extension methods for navigating the Xui view tree.

public static class ViewExtensions
Inheritance
ViewExtensions
Inherited Members

Methods

FindViewById(View, string)

Performs a depth-first search of the view subtree (including root itself) and returns the first view whose Id matches id.

public static View? FindViewById(this View root, string id)

Parameters

root View
id string

Returns

View

The matching view, or null if not found.

FindViewsByClass(View, string, List<View>)

Performs a depth-first search of the view subtree (including root itself) and collects all views whose ClassName contains className.

public static void FindViewsByClass(this View root, string className, List<View> results)

Parameters

root View
className string
results List<View>

Parents(View)

Returns an allocation-free enumerable that walks up the parent chain of a view.

public static ViewExtensions.ParentsEnumerable Parents(this View view)

Parameters

view View

The view whose parent chain should be traversed.

Returns

ViewExtensions.ParentsEnumerable

An enumerable of the view's parents, from immediate to root.

TryFindParent<T>(View, out T?)

Attempts to find the first parent of a specific type in the view tree. Zero allocations. Returns true if a matching parent was found.

public static bool TryFindParent<T>(this View view, out T? result) where T : View

Parameters

view View

The view whose parent chain will be searched.

result T

The found parent of type T, or null if not found.

Returns

bool

True if a matching parent was found; otherwise, false.

Type Parameters

T

The type of view to search for.