Class View
Base class for all UI elements in the Xui layout engine. A view participates in layout, rendering, and input hit testing, and may contain child views.
public abstract class View
- Inheritance
-
View
- Derived
- Inherited Members
Properties
Count
Returns the number of child views. Used by layout containers and traversal logic. Leaf views should return 0.
public virtual int Count { get; }
Property Value
Direction
The writing direction of this view, which determines the block or inline flow direction. Inherited from the parent flow context if set to Inherit.
public Direction Direction { get; set; }
Property Value
Flow
Controls how the layout system treats this view's children. Can be inherited or explicitly overridden for advanced layout containers.
public Flow Flow { get; set; }
Property Value
Frame
The border edge of this view in global coordinates relative to the top-left of the window.
public Rect Frame { get; protected set; }
Property Value
HorizontalAlignment
The horizontal alignment of this view inside its layout anchor region. Used during layout when the view has remaining space within its container.
public HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
this[int]
Indexer to access child views by index. Layout containers should implement this to expose their children.
public virtual View this[int index] { get; }
Parameters
index
int
Property Value
Margin
The margin around this view. Margins participate in collapsed margin logic during layout, and are external spacing relative to the parent or surrounding siblings.
public Frame Margin { get; set; }
Property Value
MaximumHeight
The maximum height of the border edge box.
public NFloat MaximumHeight { get; set; }
Property Value
MaximumWidth
The maximum width of the border edge box.
public NFloat MaximumWidth { get; set; }
Property Value
MinimumHeight
The minimum height of the border edge box.
public NFloat MinimumHeight { get; set; }
Property Value
MinimumWidth
The minimum width of the border edge box.
public NFloat MinimumWidth { get; set; }
Property Value
Parent
The parent view in the visual hierarchy. This is set automatically when the view is added to a container.
public View? Parent { get; }
Property Value
VerticalAlignment
The vertical alignment of this view inside its layout anchor region. Used during layout when the view has remaining space within its container.
public VerticalAlignment VerticalAlignment { get; set; }
Property Value
WritingMode
The writing mode of this view (e.g. horizontal top-to-bottom or vertical right-to-left). Inherited from the parent if set to Inherit.
public WritingMode WritingMode { get; set; }
Property Value
Methods
Arrange(Rect, IMeasureContext)
Arranges the view within the specified rectangle, finalizing its layout position and size.
public Rect Arrange(Rect rect, IMeasureContext context)
Parameters
rect
RectThe rectangle defining the position and exact size for the view.
context
IMeasureContext
Returns
- Rect
The rectangle occupied by the arranged view.
ArrangeCore(Rect, IMeasureContext)
Performs the layout pass by arranging content and children within the view's border edge box, using the provided rectangle.
protected virtual void ArrangeCore(Rect rect, IMeasureContext context)
Parameters
rect
RectThe final rectangle (position and size) allocated to this view's border edge box.
context
IMeasureContextThe layout metrics context providing access to platform-specific measurements, text sizing, and pixel snapping utilities.
HitTest(Point)
Determines whether the given point (in local coordinates) hits this view’s visual bounds. Used for input dispatch and hit testing.
public virtual bool HitTest(Point point)
Parameters
point
PointThe point to test, relative to this view’s coordinate space.
Returns
- bool
true
if the point is inside the view’s frame; otherwisefalse
.
Measure(Size, IMeasureContext)
Measures the view using the specified available size, returning the desired size calculated during the layout pass.
public Size Measure(Size availableSize, IMeasureContext context)
Parameters
availableSize
SizeThe maximum space available for the view to occupy.
context
IMeasureContext
Returns
- Size
The size that the view desires to occupy within the constraints.
MeasureCore(Size, IMeasureContext)
Determines the minimum size that this view's border edge box requires, given the maximum available size. Margin is not part of this size.
protected virtual Size MeasureCore(Size availableBorderEdgeSize, IMeasureContext context)
Parameters
availableBorderEdgeSize
SizeThe maximum size available for the view’s border edge box. This size excludes margins, which are handled by the parent layout.
context
IMeasureContextThe layout metrics context providing access to platform-specific measurements, text sizing, and pixel snapping utilities.
Returns
- Size
The desired size of the border edge box based on content and layout logic.
RaisePointerEvent(ref PointerEventRef, EventPhase)
Called during event dispatch to handle a pointer event in a specific event phase.
public virtual void RaisePointerEvent(ref PointerEventRef e, EventPhase phase)
Parameters
e
PointerEventRefphase
EventPhase
Render(IContext)
Renders the view using the given rendering context. This should be called after layout is complete.
public void Render(IContext context)
Parameters
context
IContextThe rendering context used to draw the view.
RenderCore(IContext)
Renders the content and children of this view using the provided rendering context.
protected virtual void RenderCore(IContext context)
Parameters
context
IContextThe drawing context used for rendering visual content to the output surface.
Update(LayoutGuide)
Performs a full layout pass for a view - measure, arrange and render.
Flags can limit to a subset of the layout passes, in case a container needs to measure children multiple times, or in case a container can rush forward without forking the layout pass into multiple sub-passes.
The layout method will delegate parts of the execution to MeasureCore(Size, IMeasureContext), ArrangeCore(Rect, IMeasureContext) and RenderCore(IContext).
If a container needs to call multiple times methods for a child, either call the Measure(Size, IMeasureContext), Arrange(Rect, IMeasureContext) and Render(IContext), or construct a LayoutGuide with the specific flags and pass it to Update(LayoutGuide).
Some containers may override and implement a Layout in a way, that it compacts the flow and avoids fork, like a VerticalStack that is placed on fullscreen (with fixed width), can arrange children top to bottom calling their Layout directly - eventually going foreach-layout without splitting into foreach-measure, foreach-arrange cycles. VerticalStack however, when centered, while it can layout children vertically in a single pass, it can't render, because it needs its height to figure out its position, so in these cases it may foreach-layout (measure and arrange) resolve the stack Y position and then foreach-layout (for render).
public virtual LayoutGuide Update(LayoutGuide guide)
Parameters
guide
LayoutGuide