ScrollView

Scroll one content tree vertically or horizontally, with paging, refresh, and keyboard behavior.

ScrollView hosts one Content view. It measures that content without a limit along the scroll axis and fills the finite viewport across it.

new ScrollView
{
    Content = new StackPanel
    {
        Padding = new Thickness(16, 20, 16, 40),
        Spacing = 12,
        Children =
        {
            new Label { Text = "Recent activity" },
            BuildActivityRows()
        }
    }
};

Vertical is the default orientation. A horizontal scroll view typically contains a horizontal StackPanel whose children have explicit or content-derived widths.

Paging and indicators

Set Paging to snap horizontal or vertical scrolling to whole viewport lengths. ShowsIndicator, IndicatorStyle, and IndicatorInsets configure the native scroll indicator.

new ScrollView
{
    Width = 320,
    Height = 200,
    Orientation = Orientation.Horizontal,
    Paging = true,
    ShowsIndicator = false,
    Content = pages
};

Scrolled reports the current offset along the active axis. ScrollTo(offset, animated) moves to a point offset programmatically.

Keyboard avoidance

AvoidsKeyboard defaults to true. The native content inset changes so a focused input is not covered by the keyboard. KeyboardDismiss defaults to Interactive, allowing the keyboard to follow a downward drag. Other modes can keep it visible or dismiss it immediately when dragging begins.

Text-input keyboard traits and accessories are covered in the TextField and TextEditor guides.

Pull to refresh

Setting RefreshCommand installs the native refresh control. Bind IsRefreshing two ways and set it back to false when the operation finishes:

new ScrollView
{
    RefreshCommand = viewModel.RefreshCommand,
    IsRefreshing = Bind(vm => vm.IsRefreshing)
        .TwoWay((vm, val) => vm.IsRefreshing = val),
    Content = content
};

RefreshCommand.CanExecute controls whether the native refresh control accepts a pull. An allowed pull sets IsRefreshing to true before executing the command. The command owns completion, including clearing the state in a finally block when refresh can fail.

Use CollectionView instead when the content is a large or changing data set that benefits from cell reuse and diffable updates.