Scroll by touching with PanningMode in WPF application – C#

Touch Screen WPF Application

If your WPF application runs on machine that have touch screen and you want to scroll your content by touching anywhere in ScrollViewer content and not been forced to use the side scrollbar, this is the solution.

First you need to add PanningMode=”Both” into the .xaml  ScrollViewer.

Example: <ScrollViewer Name=”AnyName” PanningMode=”Both”>

Ok after, when you run your application you will notice that your touch scroll works, but not perfect. The whole screen is shaking after you hit the top scroll or the bottom scroll. Don’t worry we have the solution.

Add the this to .xaml


Example: <ScrollViewer Name=”AnyName” PanningMode=”Both” ManipulationBoundaryFeedback=”ScrollViewer_ManipulationBoundaryFeedback”>

And into .xaml.cs add the following function:

void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
e.Handled = true;

Leave a Reply

Your email address will not be published. Required fields are marked *