【问题标题】:tapped event handler c# windows10c# windows 10 中点击的事件处理程序
【发布时间】:2015-09-24 17:36:59
【问题描述】:

我想添加一个点击事件来打开关于我的地图上点击的图钉的信息(在文本框或弹出窗口或任何可能的地方)

我有一张地图和一种在其上添加图钉(mapicon)的方法,我的问题是我不知道如何使用图钉作为按钮来打开某些东西以显示有关点击的图钉的信息,关闭/清理它以便为用户打开一个新的。

方法如下:

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);}

我一直在尝试这个:

MapControl1.MapElementClick += new TappedEventHandler(Info);

【问题讨论】:

    标签: c# windows icons maps


    【解决方案1】:

    您可以将 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);
    

    然后像这样处理点击事件:

     private async void Pin_Tapped(object sender, TappedRoutedEventArgs e)
     {
            // DO YOUR STUFF HERE
     }
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-07
      • 2015-03-28
      • 2011-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多