Class ScrollView
A container that clips its content and allows scrolling via pointer drag/fling and scroll wheel input. Supports vertical, horizontal, or both axes. Displays thin overlay scrollbar indicators on the relevant edges.
public class ScrollView : View, ILayerHost, IServiceProvider
- Inheritance
-
ScrollView
- Implements
- Inherited Members
- Extension Methods
Properties
Content
Gets or sets the single child view to scroll.
public View? Content { get; set; }
Property Value
Count
Number of child views.
public override int Count { get; }
Property Value
Direction
Gets or sets which axis (or axes) this scroll view responds to.
public ScrollDirection Direction { get; set; }
Property Value
this[int]
Gets the child view at the given index.
public override View this[int index] { get; }
Parameters
indexint
Property Value
ScrollbarEndInset
Inset from the end of the scroll axis reserved for the scrollbar.
public NFloat ScrollbarEndInset { get; set; }
Property Value
ScrollbarWidth
Width of the scrollbar track in points.
public NFloat ScrollbarWidth { get; set; }
Property Value
Methods
AnimateCore(TimeSpan, TimeSpan)
Override to animate this view and its children.
protected override void AnimateCore(TimeSpan previous, TimeSpan current)
Parameters
ArrangeCore(Rect, IMeasureContext)
Override to arrange children within this view's final frame.
protected override void ArrangeCore(Rect rect, IMeasureContext context)
Parameters
rectRectcontextIMeasureContext
HitTest(Point)
Determines whether the given point (in this view's local coordinates) hits this view's visual bounds. Used for input dispatch and hit testing.
public override bool HitTest(Point point)
Parameters
pointPointThe point to test, relative to this view's coordinate space.
Returns
- bool
trueif the point is inside the view's frame; otherwisefalse.
InverseTransformPoint(Point)
Maps a point from this view's local coordinate space into its parent coordinate space.
public override Point InverseTransformPoint(Point point)
Parameters
pointPoint
Returns
Remarks
This must be the inverse of TransformPoint(Point) for points that can be hit tested. It is separate so a view can support coordinate mappings that are not yet represented by the canvas transform API.
InverseTransformRect(Rect)
Conservatively maps an axis-aligned rectangle from this view's coordinate space into its parent coordinate space.
public override Rect InverseTransformRect(Rect rect)
Parameters
rectRect
Returns
Remarks
For non-translation transforms, an override must return the smallest parent-axis-aligned rectangle that encloses every transformed corner.
MeasureCore(Size, IMeasureContext)
Override to compute the desired border-edge size.
protected override Size MeasureCore(Size available, IMeasureContext context)
Parameters
availableSizecontextIMeasureContext
Returns
OnActivate()
Called when this view becomes active — it will receive events, render, and animate. Override this to start animations, subscribe to data sources, or acquire resources.
protected override void OnActivate()
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
OnScrollWheel(ref ScrollWheelEventRef)
Called when a scroll wheel or trackpad scroll event is dispatched to this view. Override to handle scroll input. Set Handled to stop propagation.
public override void OnScrollWheel(ref ScrollWheelEventRef e)
Parameters
RenderCore(IContext)
Override to render this view and its children.
protected override void RenderCore(IContext context)
Parameters
contextIContext
TransformPoint(Point)
Maps a point from this view's parent coordinate space into this view's local coordinate space.
public override Point TransformPoint(Point point)
Parameters
pointPoint
Returns
Remarks
Layout still supplies frames using the existing coordinate model. The default identity mapping deliberately preserves that behaviour until a container opts into a local coordinate transform. Containers such as ScrollView can override this to map input into their content space.
TransformRect(Rect)
Conservatively maps an axis-aligned rectangle from this view's parent coordinate space into this view's coordinate space.
public override Rect TransformRect(Rect rect)
Parameters
rectRect
Returns
Remarks
For non-translation transforms, an override must return the smallest parent-axis-aligned rectangle that encloses every transformed corner.