Windows Phone 8.1 MapIcon Click event

2019-08-13 23:14发布

问题:

I'm writing a Windows Phone 8.1 app(Windows Runtime version), and I used the MapIcon class to place the icons on the map control. However, I hope these icons can react to the "click" event so that I could show more details after a user has clicked a specific icon. I googled and wasn't able to find an answer. Is it possible, or do I have to create my own class in order to achieve this goal(and how)?

It's my first time to develop the Windows Phone 8.1 app, so any suggestions are really appreciated. Thank you.

回答1:

Instead of MapIcon you can place any XAML element on the map. Check http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn792121.aspx#showing_xaml_controls_and_shapes_on_the_map Since they are full blown XAML elements, you should be able to use Tapped event.

Also note that there is no guarantee that MapIcon objects will be displayed, they may be obscured by other elements.



回答2:

Just in case someone is looking for a solution for UWP apps: there is a new MapElementClick event handler now.