Class ViewCollection
A base class for container views that hold and manage a list of child views. Provides methods for adding, removing, rendering, and hit testing children.
public abstract class ViewCollection : View
- Inheritance
-
ViewCollection
- Derived
- Inherited Members
Fields
children
The internal list of child views contained within this view.
protected readonly List<View> children
Field Value
Properties
Content
Adds the provided views to this container during object initialization. This property is intended for use with C# object initializers and will not clear existing children.
public ReadOnlySpan<View> Content { init; }
Property Value
Count
Gets the number of child views in this collection.
public override int Count { get; }
Property Value
this[int]
Gets the child view at the specified index.
public override View this[int index] { get; }
Parameters
index
intThe index of the child to retrieve.
Property Value
- View
The child view at the given index.
Methods
Add(View)
Adds a view to this container.
public virtual void Add(View child)
Parameters
child
ViewThe view to add.
Exceptions
- InvalidOperationException
Thrown if the view already has a parent.
HitTest(Point)
Performs hit testing against the child views in reverse order (top-most first).
public override bool HitTest(Point point)
Parameters
point
PointThe point to test, in the coordinate space of this view.
Returns
- bool
True if any child was hit; otherwise, falls back to base implementation.
Remove(View)
Removes a view from this container.
public virtual void Remove(View child)
Parameters
child
ViewThe view to remove.
RenderCore(IContext)
Renders all child views using the provided rendering context.
protected override void RenderCore(IContext context)
Parameters
context
IContextThe rendering context used for drawing visual content.