简体   繁体   English

点击事件处理程序C#Windows10

[英]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.

相关问题 C# - 检查 Windows10 上是否安装了 UWP 应用 - C# - Check if a UWP app is installed on Windows10 C#Windows窗体无法在Windows10上加载不受管理的C ++ DLL - C# Windows Forms Unable to load unmanaged C++ DLL on Windows10 C#/ XAML监听事件 - C#/XAML Tapped event 如何在C#中的Windows10中显示有关Windows服务的状态更改(启动或停止)的气泡通知 - How to show bubble notification on status change (Start or stop) of windows service in windows10 in C# 使用UWP和C#刷新图像(Raspberry Pi3 Windows10 IoT) - Refresh an image using UWP and C# (Raspberry Pi3 Windows10 IoT) 适用于所有用户的 C# Windows10 启动快捷方式(通过 InstallShield 或编码) - C# Windows10 Shortcut for Startup (through InstallShield or Coding) for AllUsers 以编程方式获取已安装的应用程序可执行文件列表(Windows10,C#) - Programmatically get list of installed application executables (Windows10, C#) 在默认浏览器 (C#) Windows10 的列表中显示自己的应用程序 - Show own app in list for default browser (C#) Windows10 如何在Windows10快速访问C#中获取所有目录的列表 - How do you get a list of all directories in Windows10 Quick Access c# OnShareTarget在Windows10上激活 - OnShareTargetActivated on Windows10
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM