How to treat horizontal swipe, Windows Phone Silverlight?

1

First of all, sorry for the post, I'm on the smartphone. Well, I'm trying to deploy a burger menu in my silverlight application, I've already tried the drawer layout, but Visual Studio insists on not recognizing it. So I try to create a menu from scratch, it works, just the swipe and the transition is missing. But in the post I came to ask the swipe, how do I pick up when the user swipes right and left to open and close the menu, respectively? I have no idea how to do it, would it be a Point? Or what?

    
asked by anonymous 23.08.2015 / 06:51

1 answer

0

I was able to use WPToolkit:

1st Install the WPToolkit package

Install-Package WPToolkit

2nd Referencing the toolkit in xaml:

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

Before:

mc:Ignorable="d"

3rd Create a method inside the object that will receive the swipe action, in my case it is when the user slides over ContentPanel :

<!-- Logo, Dentro da Grid ContentPanel -->
<toolkit:GestureService.GestureListener >
    <toolkit:GestureListener DragDelta="GestureListener_DragDelta"/>
</toolkit:GestureService.GestureListener>

4th Handle handling in .cs

private void GestureListener_DragDelta(object sender, DragDeltaGestureEventArgs e)
{
      if(e.Direction == System.Windows.Controls.Orientation.Horizontal && e.HorizontalChange > 30)
      {
          painel.Visibility = System.Windows.Visibility.Visible;
      }

      else if(e.Direction == System.Windows.Controls.Orientation.Horizontal && e.HorizontalChange < -30)
      {
          painel.Visibility = System.Windows.Visibility.Collapsed;
      }

}

In case I gave 30 px to run the code, thus preventing the user from accidentally activating the panel ... You can do in Vertical too, just change the Orientation inside the if and else if to Vertical .

    
23.08.2015 / 17:11