A ScrollViewer replacement with inertia-based smooth scrolling. Supports configurable easing and duration, horizontal/vertical scroll bar visibility, scroll chaining, and programmatic scroll methods.
<SmoothScrollViewer>
<StackPanel>
<!-- long content -->
</StackPanel>
</SmoothScrollViewer>| Property | Type | Default | Description |
|---|---|---|---|
HorizontalScrollBarVisibility |
ScrollBarVisibility |
Disabled |
Disabled, Auto, Hidden, Visible |
VerticalScrollBarVisibility |
ScrollBarVisibility |
Auto |
Disabled, Auto, Hidden, Visible |
SmoothScrollEasing |
Easing? |
— | Easing function for the smooth scroll animation |
SmoothScrollDuration |
TimeSpan |
— | Duration of the smooth scroll animation |
AllowAutoHide |
bool |
inherited | Whether scroll bars auto-hide when not in use |
IsScrollChainingEnabled |
bool |
true |
Whether scrolling propagates to a parent scrollable when the limit is reached |
Offset |
Vector |
— | Current scroll offset (get/set) |
Extent |
Size |
— | Total size of the scrollable content (read-only) |
Viewport |
Size |
— | Size of the visible viewport (read-only) |
| Event | Description |
|---|---|
ScrollChanged |
Fired when scroll position, extent, or viewport size changes |
<SmoothScrollViewer SmoothScrollDuration="0:0:0.3"
SmoothScrollEasing="{x:Static Easings.CubicEaseOut}">
<ItemsControl ItemsSource="{Binding Items}" />
</SmoothScrollViewer><SmoothScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Disabled">
<StackPanel Orientation="Horizontal">
<!-- wide content -->
</StackPanel>
</SmoothScrollViewer>// Line scroll
viewer.LineUp();
viewer.LineDown();
viewer.LineLeft();
viewer.LineRight();
// Page scroll
viewer.PageUp();
viewer.PageDown();
// Jump to start / end
viewer.ScrollToHome();
viewer.ScrollToEnd();
// Set offset directly
viewer.Offset = new Vector(0, 500);HorizontalScrollBarVisibility and VerticalScrollBarVisibility can be set as attached properties on child controls:
<SmoothScrollViewer>
<TextBox SmoothScrollViewer.HorizontalScrollBarVisibility="Auto"
AcceptsReturn="True" />
</SmoothScrollViewer>Prevent scroll events from bubbling to a parent scrollable:
<SmoothScrollViewer IsScrollChainingEnabled="False">
<!-- nested scrollable content -->
</SmoothScrollViewer>