What events are triggered when Windows Phone 8 Map Control starts and stops scrolling?

I've been trying to figure out how to do this for a while and I don't seem to be going anywhere. I want to stop the timer when the user starts scrolling and starts it when the user stops. I've tried using Manipulation events, but they don't fire at all. Does anyone know what events I need, or if there is a better approach to this problem?

Thank.

+3


source to share


1 answer


Events are not triggered because it Map

intercepts them (a similar situation will be with Pivot control). If you want to be notified when the user has touched the screen and performed a FreeDrag gesture for example, you can use the Touch.FrameReported event and TouchPanel :

public MainPage()
{
    InitializeComponent();
    TouchPanel.EnabledGestures = GestureType.FreeDrag;
    Touch.FrameReported += Touch_FrameReported;
}

private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
    if (TouchPanel.IsGestureAvailable) // check only dragging 
    {
        // get point relative to Viewport
        TouchPoint mainTouch = e.GetPrimaryTouchPoint(yourMap);
        // drag started Key - down
        if (mainTouch.Action == TouchAction.Down)
           timer.Stop();

        // check if drag has completed (key up)
        if (mainTouch.Action == TouchAction.Up)
        {
            timer.Start();
            // in both cases you can use some other Properties of TouchPoint
            // do something for example dependant on coordinates 
            // double x = mainTouch.Position.X;
            // double y = mainTouch.Position.Y;
        }
    }
}

      



Note also that, since you have coordinates relative to your Map, you can check if the User has touched the screen in the map area (relative coordinates and map dimensions).

+2


source







All Articles