Build with XuiView Markdown

Scrolling and trackpads

Start with ScrollView for content that exceeds its viewport. It already coordinates drag recognition, wheel input, clipping, scroll indicators, and return-to-bounds motion. Override wheel handling only when the interaction truly is something other than ordinary scrolling.

Give the viewport a finite size

Place tall content inside a scroll view, then give the scroll view the space available on the page. A vertical scroller measures its child with unconstrained height but needs a bounded viewport to have anything to scroll.

This construction fragment belongs where you build a page's content:

var rows = new Xui.Core.UI.VerticalStack();
for (var index = 1; index <= 30; index++)
    rows.Add(new Xui.Core.UI.Label { Text = $"Row {index}", MinimumHeight = 48 });

var scroller = new Xui.Core.UI.ScrollView
{
    MinimumHeight = 420,
    MaximumHeight = 420,
    Direction = Xui.Core.UI.ScrollDirection.Vertical,
    Content = rows
};

ScrollOffset reports the current displacement, including elastic overscroll. ScrollChanged reports changes during dragging, inertia, and rebound; use it for an indicator rather than independently integrating wheel deltas. Unsubscribe long-lived observers when their owner stops using the scroller.

Understand wheel data

ScrollWheelEventRef.Delta carries the movement. Position is meaningful only when HasPosition is true. IsPrecise identifies a source that reports precise continuous deltas; it does not mean β€œthe fingers are still touching.”

Phase describes direct scrolling when available. MomentumPhase describes inertia already generated by the platform. Those deltas already decelerate: adding another fling on top can make motion feel wrong. macOS supplies these native phase fields. The current browser bridge supplies deltas and position without phase or momentum information, so shared code cannot reliably identify finger contact there. A slowing sequence is not proof of release.

Let nested controls cooperate

Wheel routing starts at the deepest hit view and bubbles until Handled is true. Set it when you consume an event, and leave it alone when you deliberately want an ancestor to handle it. Nested scroll regions do not automatically imply a seamless handoff at every boundary; exercise both axes and edge cases in your target hosts.

Pointer scrolling also observes capture markers. An ITap candidate can yield to a scrolling drag; an IDrag surface such as a drawing pad keeps ownership. Bounce behavior depends on device service and motion preferences, so the same view can behave differently in a phone emulator and a browser desktop host. Test the interaction, not merely the screenshot.