Class ViewExtensions
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
Returns
- View
The matching view, or
nullif 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
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
viewViewThe 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
viewViewThe view whose parent chain will be searched.
resultTThe found parent of type
T, or null if not found.
Returns
- bool
True if a matching parent was found; otherwise, false.
Type Parameters
TThe type of view to search for.