ScrollViewer provides a viewport with optional horizontal/vertical scrollbars for any content.
new ScrollViewer(new VStack(
"Line 1",
"Line 2",
"Line 3"
));
ScrollViewer is typically used as the outer container around long content:
new Border(
new ScrollViewer(new TextArea("... lots of text ..."))
.MinHeight(8)
.MaxHeight(8));
IScrollableIf Content implements IScrollable, ScrollViewer delegates scrolling to the content’s ScrollModel.
This enables controls like TextArea to own their own extent and viewport logic.
If Content does not implement IScrollable, ScrollViewer provides an internal scroll model and performs
viewport clipping/offsetting automatically.
IScrollable is the recommended contract for any control that has intrinsic scrolling behavior
(text editors, virtualized lists/grids). It allows:
ScrollViewer under the pointer.Shift + wheel (when supported by the host) scrolls horizontally.ScrollViewer distinguishes:
When the extent exceeds the viewport, ScrollViewer:
If you expect scrollbars to appear, prefer bounding one axis (MinHeight/MaxHeight or MinWidth/MaxWidth)
so the control has a reason to clip and scroll.
HorizontalAlignment = Align.Stretch, VerticalAlignment = Align.StretchScrollViewerStyle controls scrollbar thickness and color palette.
ScrollBarStyle controls track/thumb colors and glyphs.