Search code examples
c#uwpmapstouch-event

Touch events interception and routing


I have a MapControl and I am showing a MapIcon in the center of the map, which I update every second and center again. This works nice.

But now, I am trying to disable all gestures and touch events for the MapControl without success. The closest I have been to accomplish this is disabling all the four InteractionModes like PanInteractionMode. But if you try to drag the map with two fingers, it is still dragged and this is not acceptable.

On top on that, the MapControl is inside a Pivot control and I would like to route the MapControl events towards the Pivot so it can detect swipe gestures over the map too.

Am I dreaming too much?


Solution

  • When I set the following four interaction modes to Disabled, I can no longer interact with the map. I am on Windows 10 Creators Update.

    But even with them plus setting IsHitTestVisible to False, the MapControl would still swallow any input. The workaround is to overlay a transparent Rectangle. This way the swipe on Pivot will work again.

    <PivotItem Header="PivotItem 0">
        <Grid>
            <Maps:MapControl PanInteractionMode="Disabled"
                             RotateInteractionMode="Disabled"
                             TiltInteractionMode="Disabled"
                             ZoomInteractionMode="Disabled"
                             IsHitTestVisible="False" />
            <Rectangle Fill="Transparent" />
        </Grid>
    </PivotItem>