Class LayerView<TView, TLayer>
A View that owns a single TLayer struct and delegates
every layout, rendering, and input override to it, passing itself as the fully-typed
TView host to every layer method.
Because the compiler resolves TLayer statically, all delegation is
devirtualised and inlined by the JIT — zero overhead compared to writing the overrides by hand.
Child views: This class is a leaf by default (Count = 0). Subclasses that host child View instances should override Count and this[int], and manage attachment via SetProtectedChild<T>(ref T?, T?). Use ContentLayer to bridge those views back into the layer tree.
public class LayerView<TView, TLayer> : View, ILayerHost, IServiceProvider where TView : View where TLayer : struct, ILayer<TView>
Type Parameters
TViewThe concrete view subclass. Must be the class that inherits this. Pass View when no specific host type is needed.
TLayerThe layer struct type.
- Inheritance
-
LayerView<TView, TLayer>
- Implements
- Derived
- Inherited Members
- Extension Methods
Fields
Layer
The layer struct that owns all layout and rendering logic for this view.
protected TLayer Layer
Field Value
- TLayer
Methods
AnimateCore(TimeSpan, TimeSpan)
Per-frame animation hook. Mutate time-based state and call RequestAnimationFrame() if the animation should continue. The default implementation recurses into children; override to customise child traversal.
protected override void AnimateCore(TimeSpan previousTime, TimeSpan currentTime)
Parameters
ArrangeCore(Rect, IMeasureContext)
Positions children within the border-edge rectangle. Frame assignment and alignment offset are handled by ArrangeShell(ref LayoutGuide).
protected override void ArrangeCore(Rect rect, IMeasureContext context)
Parameters
rectRectcontextIMeasureContext
MeasureCore(Size, IMeasureContext)
Returns the desired border-edge size given the available border-edge space. Margin, min/max clamping, and fixed-size short-circuit are handled by MeasureShell(ref LayoutGuide).
protected override Size MeasureCore(Size availableSize, IMeasureContext context)
Parameters
availableSizeSizecontextIMeasureContext
Returns
OnBlur()
Called when this view loses keyboard focus.
protected override void OnBlur()
OnChar(ref KeyEventRef)
Called when a character is input while this view has focus.
public override void OnChar(ref KeyEventRef e)
Parameters
OnFocus()
Called when this view receives keyboard focus.
protected override void OnFocus()
OnKeyDown(ref KeyEventRef)
Called when a key is pressed while this view has focus.
public override void OnKeyDown(ref KeyEventRef e)
Parameters
OnPointerEvent(ref PointerEventRef, EventPhase)
Called during event dispatch to handle a pointer event in a specific event phase.
public override void OnPointerEvent(ref PointerEventRef e, EventPhase phase)
Parameters
ePointerEventRefphaseEventPhase
RenderCore(IContext)
Draws this view's content and recurses into children.
protected override void RenderCore(IContext context)
Parameters
contextIContext