[英]tapped event handler c# windows10
I want to add a tapped event which open information (in textbox or popup or whatever it's possible) about the tapped pin on my map 我想添加一个窃听事件,以打开有关我地图上的窃听钉的信息(在文本框或弹出式窗口中,或在可能的情况下)
I've a map and a method to add pins (mapicon) on it, my problem is that i don't know how to use a pin as a button to open something to show information about the pin tapped, close/clean it in order to open a new one up to the user. 我有一个地图和一种在上面添加大头针(mapicon)的方法,我的问题是我不知道如何使用大头针作为按钮来打开某些东西来显示有关被轻敲的大头针的信息,然后关闭/清洁它。为了向用户开放一个新的。
here is the method: 这是方法:
private void addgreenpin(double latitude, double longitude, string nom){
BasicGeoposition lugar = new BasicGeoposition()
{
Latitude = latitude,
Longitude = longitude
};
var places = new Geopoint(lugar);
MapIcon mapIcon1 = new MapIcon();
mapIcon1.Location = places;
mapIcon1.NormalizedAnchorPoint = new Point(0.1, 0.2);
mapIcon1.Title = nom;
mapIcon1.Image = mapIcon2StreamReference;
mapIcon1.ZIndex = 4;
MapControl1.MapElements.Add(mapIcon1);}
i've been trying this : 我一直在尝试:
MapControl1.MapElementClick += new TappedEventHandler(Info);
In place of MapIcon you can add XAML content to your map, something like this: 可以将XAML内容添加到地图中,以代替MapIcon,如下所示:
var pin = new Grid();
pin.Tapped += Pin_Tapped; //Binding tap event for current pin.
pin.Children.Add(new Ellipse()
{
Fill = new SolidColorBrush(Colors.DodgerBlue),
Stroke = new SolidColorBrush(Colors.White),
StrokeThickness = 1,
Width = 20,
Height = 20,
});
MapControl.SetLocation(pin, <GeoPoint_Where_You_Need_The_Pin>);
mapControlName.Children.Add(pin);
and then handle the tap event something like this: 然后处理如下的tap事件:
private async void Pin_Tapped(object sender, TappedRoutedEventArgs e)
{
// DO YOUR STUFF HERE
}
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.