Example detecting swipes in 1 axis
You can apply this to any page element, a text box for instance. In this example we use the canvas, but you don’t have to.
In your .xaml file
<Canvas x:Name="OurCanvas" Width="800" Height="1513"
ManipulationMode="TranslateX, TranslateInertia, System"
ManipulationDelta="SwipeToScroll_ManipulationDelta"
ManipulationCompleted="SwipeToScroll_ManipulationCompleted"
>
In your .cs code
private void SwipeToScroll_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
if (e.IsInertial)
{
var SwipedDistance = e.Cumulative.Translation.X;
//Check for min swipe distance
if (Math.Abs(SwipedDistance ) <= 10)
return;
if (SwipedDistance > 0)
{
//Scroll to top
PageScrollViewer.ChangeView(0, 0, 1); //horizontalOffset, verticalOffset, zoomFactor
}
else
{
//Scroll to bottom
PageScrollViewer.ChangeView(0, PageScrollViewer.ScrollableHeight, 1);
}
}
}
private void SwipeToScroll_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
//Remove this event if you don't want it...
}
