How to treat Swipe horizontal, Windows Phone Silverlight?

Asked

Viewed 30 times

1

First of all, I’m sorry about the post. Well, I’m trying to deploy a hamburger menu in my application Silverlight, I’ve tried Drawer layout, but Visual Studio insists on not recognizing it. So I try to create a menu from scratch, it’s working, just the Swipe and the transition. But in the post I came to ask from Swipe, how do I capture when the user swipes left and right to open and close the menu respectively? I have no idea mind how to do, it would be a Point ? Or what?

1 answer

0


I got it using Wptoolkit:

first Install the Wptoolkit package

Install-Package WPToolkit

2nd Reference Toolkit in the shampoo:

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

Before:

mc:Ignorable="d"

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

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

fourth 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 him a 30 px slack to execute the code, thus preventing the user from accidentally activating the panel... You can do Vertical too, just change the Orientation within the if and else if for Vertical.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.