Touch gesture in WPF scroll viewer

WPF 4.0 comes up with attractive features. One of them is Multi touch. We can play with WPF scroll viewer using  finger. Setting the property PanningMode will do the magic.

   <ScrollViewer PanningMode="Both" 
              HorizontalScrollBarVisibility="Auto"
              VerticalScrollBarVisibility="Auto"/>

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.


Member name Description
None The ScrollViewer does not respond to touch input.
HorizontalOnly The ScrollViewer scrolls horizontally only.
VerticalOnly The ScrollViewer scrolls vertically only.
Both The ScrollViewer scrolls horizontally and vertically.
HorizontalFirst The ScrollViewer scrolls when the user moves a finger horizontally first. If the user moves the vertically first, the movement is treated as mouse events. After the ScrollViewer begins to scroll, it will scroll horizontally and vertically.
VerticalFirst The ScrollViewer scrolls when the user moves a finger vertically first. If the user moves the horizontally first, the movement is treated as mouse events. After the ScrollViewer begins to scroll, it will scroll horizontally and vertically.

Leave a comment

Up ↑