* net-current-v30plus-md.md * net-current-v40plus-md.md * tla2sharptla-ui-md.md * tla2sharptla-uiautomation-md.md * tla2sharptla-winclient-md.md * tla2sharptla-xaml-md.md * tlasharptla-ui-md.md * tlasharptla-uiautomation-md.md * tlasharptla-winclient-md.md * tlasharptla-xaml-md.md * fix warnings
1.9 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||||
|---|---|---|---|---|---|---|---|---|---|
| How to: Use the Content-Scrolling Methods of ScrollViewer | 03/30/2017 |
|
|
4708cc65-6510-45f8-82e6-30b0d3e30045 |
How to: Use the Content-Scrolling Methods of ScrollViewer
This example shows how to use the scrolling methods of the xref:System.Windows.Controls.ScrollViewer element. These methods provide incremental scrolling of content, either by line or by page, in a xref:System.Windows.Controls.ScrollViewer.
Example
The following example creates a xref:System.Windows.Controls.ScrollViewer named sv1, which hosts a child xref:System.Windows.Controls.TextBlock element. Because the xref:System.Windows.Controls.TextBlock is larger than the parent xref:System.Windows.Controls.ScrollViewer, scroll bars appear in order to enable scrolling. xref:System.Windows.Controls.Button elements that represent the various scrolling methods are docked on the left in a separate xref:System.Windows.Controls.StackPanel. Each xref:System.Windows.Controls.Button in the XAML file calls a related custom method that controls scrolling behavior in xref:System.Windows.Controls.ScrollViewer.
[!code-xamlScrollViewerMethods#1]
The following example uses the xref:System.Windows.Controls.ScrollViewer.LineUp%2A and xref:System.Windows.Controls.ScrollViewer.LineDown%2A methods.
[!code-csharpScrollViewerMethods#2] [!code-vbScrollViewerMethods#2]