简体   繁体   中英

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.

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:

        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:

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

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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