Handling Manipulation Events with Page Class RRS feed

  • Question

  • I'm trying to make an application that when a user swipes a finger to the left or right the application reads this and says that a left or right swipe was made.

    How I'm trying to accomplish this is to add a ManipulationStartedEventHandler and a ManipulationCompletedEventHandler to my MainPage class that is created on project creation. Then take the two points and get the direction.

    In the constructor of the main page, I've got:

    this->ManipulationStarted += ref new ManipulationStartedEventHandler( this, &MainPage::OnManipulationStarted );
    this->ManipulationCompleted += ref new ManipulationCompletedEventHandler(this, &MainPage::OnManipulationCompleted);

    In order to handle the manipulations but when I put a breakpoint in these functions I never get a break. I'm wondering why I'm not getting the events to register. I've tried setting the ManipulationMode of the page to All, but that doesn't work either.

    Does anyone have any suggestions to what I'm doing wrong?


    Thursday, May 17, 2012 8:03 PM

All replies

  • I'm not sure why your manipulation events don't get hit. When I do the same in a test app the manipulation events on my page do trigger. Do you have other controls on the page which may be handling the manipulation?

    It may help if you could provide a minimal sample which reproduces the problem.

    In addition to the manipulation start and end you probably will want to handle ManipulationDelta so you can provide feedback during the swipe. If you set the ManipulationMode to TranslateX then you can apply the ManipulationDelta's transform to the Page during the swipe so users can see their input is being handled. See Guidelines for visual feedback.

    You might also want to look at the GestureRecognizer's cross-slide detection rather than rolling your own.



    Friday, May 18, 2012 12:13 AM
  • Hey Rob,

    I've looked into the GestureRecognizer but I didn't think that it would work for what I want.

    Is there a way to attach a GestureRecognizer to a page? Or do I have to pass events to it's process up/down event?


    Friday, May 18, 2012 2:36 PM
  • I'm having the same issue.  The only difference is I'm adding my handlers in Xaml.  I can get certain non-manipulation event to trigger.
    Thursday, October 25, 2012 6:29 PM