简体   繁体   English

UWP Mapcontrol-向元素添加工具提示吗?

[英]UWP Mapcontrol - add tooltip to element?

I have a bunch of MapIcons defined similarly to this: 我有一堆与此相似的MapIcons定义:

Geopoint t_pt = new Geopoint(new BasicGeoposition() { Latitude = -50.05, Longitude = 22.12 });
MapIcon t_icon = new MapIcon { Location = t_pt };
t_icon.Title ="My_Title";
MainMap.MapElements.Add(t_icon);

These display on MainMap with no problem. 这些显示在MainMap上没有问题。 But I would like to add a tooltip to each MapIcon that displays, for example, the Icon title. 但是我想向显示的每个MapIcon添加工具提示,例如Icon标题。 I have tried this: 我已经试过了:

ToolTipService.SetToolTip(t_icon, "HI");

As a test but when I mouseover the MapIcon nothing is displayed. 作为测试,但是当我将鼠标悬停在MapIcon上时,没有显示任何内容。 Tooltips work find if I mouseover other controls (such as a button or listbox), though. 但是,如果我将鼠标悬停在其他控件(例如按钮或列表框)上,则工具提示会起作用。

Any ideas? 有任何想法吗?

Tool tips only work with XAML elements - a MapIcon is not a XAML UI element. 工具提示仅适用于XAML元素-MapIcon不是XAML UI元素。 You can either implement the tooltip yourself by listening to the MapPointerEntered/Exited event and displaying a XAML rectangle with text, or you can use XAML elements added to the map control as children instead of MapIcon for your pushpins (not recommended if you have a lot of items). 您可以通过侦听MapPointerEntered / Exited事件并显示带有文本的XAML矩形来自己实现工具提示,也可以将添加到地图控件中的XAML元素作为子控件而不是MapIcon用作图钉(如果您的图钉太多,则不建议使用项)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM