Bing Map on Windows Phone - add click events to pushpins; display more details
- by Will Gill
I have a WP Phone app using a Bing Map control. I have an array of objects, and each object has a location. I iterate the array to place the pins on the map (see below). I have a touch event bound to each pin to allow the user to tap the pin to start an action.
Now - I would like, on tap, to show information from the object that relates to that pin to be shown in a textbox. How can I retrieve the object from the array that corresponds to the pushpin that was tapped/clicked?
foreach (wikiResult result in arrayResults)
{
double lat = double.Parse(result.Latitude, CultureInfo.InvariantCulture);
double lng = double.Parse(result.Longitude, CultureInfo.InvariantCulture);
statusTextBlock.Text = result.Latitude + " " + result.Longitude + " " + lat + " " + lng;
GeoCoordinate d = new GeoCoordinate(lat, lng);
Pushpin pin;
pin = new Pushpin();
pin.Location = d;
pin.Content = result.Name;
pin.MouseLeftButtonUp += new MouseButtonEventHandler(pin1_MouseLeftButtonUp);
myMap.Children.Add(pin);
}
void pin1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
//display the content from the object in a text box
}
Many thanks in advance!