ScrollViewer. A ScrollViewer scrolls other controls. It is used as a container. We drag (or otherwise add) controls, nesting them inside the ScrollViewer.
Getting started. To use a ScrollViewer please open the Toolbox and drag the control to your Window. So try dragging some Button controls to its interior area.
In this example, I added a StackPanel to the interior of the ScrollViewer. In a StackPanel, controls are "stacked" in one direction.
Discussion. ScrollViewer is a layout control—it requires you to add controls to it before it is useful. Once you do this, though, you get a region that expands as much as needed.
Info You won't need to redesign your entire program just to add another button or TextBlock description.
Options dialog. Sometimes when designing programs, a "Preferences" dialog (Options) is a burden. At first, these windows have few controls—so you can just add Buttons to a Grid.
But As time passes, the program becomes more complex. At that point, a ScrollViewer might be helpful.
And It will scroll as far as needed. Responsive layouts, like the ScrollViewer, are easiest to work with.
Summary. WPF is full of useful controls. A ScrollViewer is not needed in many programs. But in "Options" windows, or other complex dialogs, it has its place.
Dot Net Perls is a collection of pages with code examples, which are updated to stay current. Programming is an art, and it can be learned from examples.
Donate to this site to help offset the costs of running the server. Sites like this will cease to exist if there is no financial support for them.
Sam Allen is passionate about computer languages, and he maintains 100% of the material available on this website. He hopes it makes the world a nicer place.
This page was last updated on Sep 29, 2022 (edit).