Search code examples
c#eventsuwpmapsuwp-maps

MapHolding action on MapControl doesn't work... a workaround?


It seems that holding method does not work since 2015:
Win10 App - Holding & Releasing the map to manipulate an element on the interface

or simply I don't know how to use it, anyway I need to manage a user holding on PC or mobile of a map.

My map is like a navigator, it follows the user position while it is moving, but when user use gesture to see the map around I have to stop the .center position of the user pushpin.

But I cannot find a way to understand when user move the map. The docs tell to use the holding event https://learn.microsoft.com/it-it/windows/uwp/maps-and-location/display-maps

but I've tried it on PC and my app doesnt enter in the holding event.

I've tried all the other events, only maptapped and actualcamerachanged works. but I don't know how to difference from a user move or a map .center move from the app.

Any help?

Thanks!


Solution

  • I resolved with a little of WinMerge and some try

    you can find the FocusState.Pointer in sender when the user try to move the map, if not with the map.center you get a FocusState.Unfocused by the sender

    private void Mappe_ActualCameraChanged(MapControl sender, MapActualCameraChangedEventArgs args)
             {
                if (sender.FocusState == FocusState.Pointer)
                {
    
                }
    
            }