locked
Swipe gesture in winrt Metro app RRS feed

  • Question

  • Hello. I want to implement Swipe gesture in my app.

    Have found this example on forum. It works, but I wish te let Swipe be handled only if it slide for just a short distance.

    It this example I can slide for 300 pixels - event anyway will be handled. And will be handled 2 or 3 times, not only once.


    Monday, June 11, 2012 1:46 PM

Answers

All replies

  • You'll want to look at the ManipulationStarted/ManipulationDelta events of the control that is being swiped.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    Monday, June 11, 2012 7:36 PM
    Moderator
  • So, the best ( and may be the only ) way is to get start position and check movement position/positions, and leave gesturerecognizer?
    Monday, June 11, 2012 7:52 PM
  • Yes.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    Wednesday, June 13, 2012 1:26 PM
    Moderator
  • You'll want to look at the ManipulationStarted/ManipulationDelta events of the control that is being swiped.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    When I pressed mouse and swipe right, there is only ManipulationStarting event, no ManipulationDelta.

    How can I get the current point position and completed movement position?


    Charlie Chang L

    Sunday, August 26, 2012 4:55 PM
  • hi,

    i also have doubt in swipe gesture recognition. what should i do in 

      void gestureRecognizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs args)
            {}

    method so that as i drag or swipe my rectangle( UIelement) it moves accordingly. 


    Aruna Bhayani

    Wednesday, September 12, 2012 12:22 PM
  • Charlie, as I have understand - it will looking out like this:

    private Point initialpoint;
    
    private void ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
    {
        initialpoint = e.Position;
    }
    
    private void ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
    {
        Point currentpoint = e.Position;
        if (currentpoint.X - initialpoint.X >= 100)
        {
            System.Diagnostics.Debug.WriteLine("Swipe Right");
            e.Complete();
        }
    }
     And don't forget to set ManipulationMode in XAML

    Wednesday, December 26, 2012 1:36 PM