Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-use-the-content-scrolling-methods-of-scrollviewer.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

2.0 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
csharp
vb
IScrollInfo interface [WPF]
scrolling methods [WPF]
ScrollViewer control [WPF], scrolling methods
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 [!INCLUDETLA2#tla_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]

See also