ScrollViewer.PanningMode Property

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets the way ScrollViewer reacts to touch manipulation.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public PanningMode PanningMode { get; set; }

Property Value

Type: System.Windows.Controls.PanningMode

A value that specifies how ScrollViewer reacts to touch manipulation. The default is None.

ThePanningMode property specifies whether the ScrollViewer scroll horizontally, vertically, or both. The ScrollViewer will scroll when a user drags a finger on the control on a touch device that supports Windows Touch.

PanningMode can be either set directly on a ScrollViewer or used as an attached property. When a control contains a ScrollViewer in its ControlTemplate, use ScrollViewer.PanningMode as an attached property to specify the behavior of the ScrollViewer in the ControlTemplate. When you use a ScrollViewer outside of a ControlTemplate, set PanningMode directly on the ScrollViewer.

The following example creates a ScrollViewer and adds several elements to it. In this example, when the size of the window changes, the size of textblock1 also changes. When the TextBlock is too small to display all of the content, the ScrollViewer becomes scrollable. The example sets PanningMode to Both so that the user can scroll the ScrollViewer horizontally and vertically by using a finger.

The following example creates a TextBox and uses ScrollViewer.PanningMode as an attached property. By default the ScrollViewer in the ControlTemplate of a TextBox has its PanningMode to VerticalFirst. This is so that when the user moves a finger horizontally before moving it vertically, the user highlights text. The example sets PanningMode to VerticalOnly so that the user cannot select text by using a finger. Note that setting PanningMode to Both also prevents the user from selecting text. The example sets the TextWrapping property to Wrap, so horizontal scrolling is not necessary.

.NET Framework
Available since 4.0
Return to top