How should I handle click events on pushpins in my Bing Maps control for WP7

前端 未结 3 900
醉梦人生
醉梦人生 2021-01-25 05:32

I\'m about to add templated

3条回答
  •  走了就别回头了
    2021-01-25 05:40

    If all you want is to be able to click/tap on each pushpin, add a MouseLeftButtonUp event to each pushpin you create. For example:

    Microsoft.Phone.Controls.Maps.Pushpin pp = null;
    System.Device.Location.GeoCoordinate loc = null;
    
    pp = new Microsoft.Phone.Controls.Maps.Pushpin();
    loc = new System.Device.Location.GeoCoordinate([Latitude], [Longitude]);
    
    pp.Location = loc;
    pp.Content = "Some Content";
    pp.MouseLeftButtonUp += new MouseButtonEventHandler(Pushpin_MouseLeftButtonUp);
    

    then you add

    void Pushpin_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
         Microsoft.Phone.Controls.Maps.Pushpin tempPP = new Microsoft.Phone.Controls.Maps.Pushpin();
    
         tempPP = (Microsoft.Phone.Controls.Maps.Pushpin)sender;
    
         // you can check the tempPP.Content property
    
    } 
    

提交回复
热议问题