{"id":1395,"date":"2025-04-17T12:19:50","date_gmt":"2025-04-17T11:19:50","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=1395"},"modified":"2025-04-17T12:19:50","modified_gmt":"2025-04-17T11:19:50","slug":"detecting-swipes","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/windows-and-pages\/pages\/detecting-swipes","title":{"rendered":"Detecting swipes"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Example detecting swipes in 1 axis<\/h4>\n\n\n\n<p>You can apply this to any page element, a text box for instance.  In this example we use the canvas, but you don&#8217;t have to.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">In your .xaml file<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>        &lt;Canvas x:Name=\"OurCanvas\" Width=\"800\" Height=\"1513\"\n                ManipulationMode=\"TranslateX, TranslateInertia, System\"\n                ManipulationDelta=\"SwipeToScroll_ManipulationDelta\"\n                ManipulationCompleted=\"SwipeToScroll_ManipulationCompleted\"\n                ><\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">In your .cs code<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\tprivate void SwipeToScroll_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)\n\t\t{\n\t\t\tif (e.IsInertial)\n\t\t\t{\n\t\t\t\tvar SwipedDistance = e.Cumulative.Translation.X;\n\n\t\t\t\t\/\/Check for min swipe distance\n\t\t\t\tif (Math.Abs(SwipedDistance ) &lt;= 10)\n\t\t\t\t\treturn;\n\n\t\t\t\tif (SwipedDistance  > 0)\n\t\t\t\t{\n\t\t\t\t\t\/\/Scroll to top\n\t\t\t\t\tPageScrollViewer.ChangeView(0, 0, 1);       \/\/horizontalOffset, verticalOffset, zoomFactor\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t\/\/Scroll to bottom\n\t\t\t\t\tPageScrollViewer.ChangeView(0, PageScrollViewer.ScrollableHeight, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tprivate void SwipeToScroll_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)\n\t\t{\n\t\t\t\/\/Remove this event if you don't want it...\n\t\t} <\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t have to. In your .xaml file In your .cs code<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[],"class_list":["post-1395","post","type-post","status-publish","format-standard","hentry","category-pages"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=1395"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1395\/revisions"}],"predecessor-version":[{"id":1396,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1395\/revisions\/1396"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=1395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=1395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=1395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}