# .NET and More > WPF, WCF, WF >  UWP MapControl events do not happen, but I've found a workaround....

## sdellava

Dear all, 

this time I'm not writing to ask help in found a solution but to understand why the solution I've found works  :Smilie: 

I've a simple map control in my XAML:

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Expedition_map_tool"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:maps="using:Windows.UI.Xaml.Controls.Maps"
    x:Class="Expedition_map_tool.MainPage"
    mc:Ignorable="d" Width="Auto" Height="Auto">

        <maps:MapControl  Grid.Column="1" Grid.ColumnSpan="4" x:Name="MyMap" ZoomInteractionMode="GestureOnly" RotateInteractionMode="Disabled" TiltInteractionMode="GestureAndControl" PanInteractionMode="Auto" MapServiceToken="...... " Canvas.ZIndex="0" />


---- other controls here -------


</Page>

If I try to catch the mouse movement whit the event procedure

Private Sub MyMap_PointerMoved(sender As Object, e As PointerRoutedEventArgs) Handles MyMap.PointerMoved

...... 

End sub


nothing happen, but if I add a simple Stack Panel over the map it work, like this:


        <StackPanel x:Name="overlay" Grid.Column="1"  Grid.ColumnSpan="3" Canvas.ZIndex="5" Background="Transparent" IsHitTestVisible="False" />


all the mouse events on the map start working... *WHY ?????*

Thanks, Stefano

----------


## jmcilhinney

I don't know the answer to your question but I just read this in the documentation for that event:



> For touch actions and also for interaction-specific or manipulation events that are consequences of a touch action, an element must be hit-test visible in order to be the event source and fire the event that is associated with the action. UIElement.Visibility must be Visible. Other properties of derived types also affect hit-test visibility. For more info, see Events and routed events overview.


My first guess would be that adding the StackPanel affects the hit-test visibility of your MapControl.

----------


## Sitten Spynne

I'm confused about the XAML you posted. A Page has a single bit of content, and if you want to place multiple controls on a Page then you make its content a Panel, then add the controls to that panel. For example, I'd expect to see a Grid or StackPanel or similar Panel as the content of the Page, but your example implies you're just adding a bunch of elements to the Page. I'm not really sure what happens when you do that.

I'm not really sure if any of my machines has the infrastructure needed to develop UWP installed, but if I happen to find one that does I'll give it a whirl.

----------


## sdellava

> I don't know the answer to your question but I just read this in the documentation for that event:
> 
> My first guess would be that adding the StackPanel affects the hit-test visibility of your MapControl.



Ok, thanks. Not exacltly clear what the Hit-test is, but I'll look for additional info online.

----------


## sdellava

Yes, a Grid container is missing in my xaml, just to simplifying the post. Anyway is seems an the empty stackpanel is needed. Otherwise not events is generated by the map control.

----------

