Wpf Bing api & Pushpin

618 views Asked by At

Question about bing api Wpf sdk and c#...

I'm using this code to create and place PushPins on my map. But... ClickOnPushpin EventHandler is not working...

    private void AddPushPin(IpInfo nfo)
    {
        double lat = Convert.ToDouble(nfo.dLat,  CultureInfo.InvariantCulture);
        double lon = Convert.ToDouble(nfo.dLong, CultureInfo.InvariantCulture);

        Pushpin pin = new Pushpin();
        pin.Location = new Location(lat, lon);

        pin.MouseDown += new MouseButtonEventHandler(ClickOnPushpin);

        MyMap.Center = pin.Location;
        MyMap.Children.Add(pin);
    }

    private void ClickOnPushpin(object sender, MouseButtonEventArgs e)
    {
        //DoWhateverYouWant
    }

Any help?

Thanks!

1

There are 1 answers

0
rbrundritt On

I tried your code as is and it worked in the WPF map control. The mouse events on the map wouldn't cause any issue here. I've been using this method of adding click events to pushpin sin the WPF map control for years.