Results 1 to 5 of 5

Thread: UWP MapControl events do not happen, but I've found a workaround....

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2017
    Posts
    14

    UWP MapControl events do not happen, but I've found a workaround....

    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

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: UWP MapControl events do not happen, but I've found a workaround....

    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.

  3. #3
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: UWP MapControl events do not happen, but I've found a workaround....

    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.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2017
    Posts
    14

    Re: UWP MapControl events do not happen, but I've found a workaround....

    Quote Originally Posted by jmcilhinney View Post
    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2017
    Posts
    14

    Re: UWP MapControl events do not happen, but I've found a workaround....

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width