I have this Windows Phone app I need to do that gets information from the Google places API about places that the user searches for. For each place I need to have a pushpin on a bing map I have inserted. The problem is that I'm a newbie in c# and I don't know how to do what I need. I need to customize each pushpin so that it shows its content when it's tapped on. Also, I want the content to be a textBlock a small image and a button (or icon) for directions from a pushpin designated as the current location of the user. So far I have inserted the text and the button but I'm walking blind here and I could use some example code to look at. It is important that everything is done from the c# side of things and not from the xaml because the specific attributes of each pushpin is extracted from an XML file returned by Google Places API. Thank you very much.

My code so far:

  private void put_pins_on_map()
            //-------------------------------get xml file from isolated storage-------------------------------
            IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();

            if (file.FileExists("data.xml"))
                StreamReader sreader = new StreamReader(file.OpenFile("data.xml", FileMode.Open));
                string xml_data = sreader.ReadToEnd();

                //-------------------------------never mind this part---------------------------------------------
                int bom_index = xml_data.IndexOf('<'); 
                if (bom_index > 0)
                { xml_data = xml_data.Remove(0, bom_index); }

                //-----------------------------XML Processing-----------------------------------------------------
                XmlReader reader = XmlReader.Create(sreader);
                scrollViewer1.Content = sreader.ReadToEnd();

                //------------------using LINQ to extract necessary info from XML---------------------------------
                XElement data_elements = XElement.Parse(xml_data);
                var results = from element
                              in data_elements.Elements("result")
                              select element;

                foreach (XElement child_elements in results)
                    //--------------------new pin-------------------------------
                    string lat, lng;
                    Pushpin pin = new Pushpin();
                    Grid pin_grid = new Grid();
                    Image place_thumbnail = new Image();
                    TextBlock pin_text = new TextBlock();
                    Button directions_button = new Button();

                    if (child_elements.Element("name") != null)
                    { pin_text.Text += "Name: " + child_elements.Element("name").Value + System.Environment.NewLine; }
                    if (child_elements.Element("formatted_address") != null)
                    { pin_text.Text += "Address: " + child_elements.Element("formatted_address").Value + System.Environment.NewLine; }

                    pin_text.Text = pin_text.Text + "Type: ";

                    foreach (XElement type_node in child_elements.Descendants())
                        if (type_node.Name == "type")
                        { pin_text.Text += type_node.Value + " "; }


                    if (child_elements.Element("rating") != null)
                    { pin_text.Text += "Rating: " + child_elements.Element("rating").Value + System.Environment.NewLine + System.Environment.NewLine; }

                    //---------------------the difficult part-----------------------------------------
                    //---------------------pin customization------------------------------------------
                    lat = child_elements.Element("geometry").Element("location").Element("lat").Value;

                    lng = child_elements.Element("geometry").Element("location").Element("lng").Value;

                    pin.Location = new GeoCoordinate(Convert.ToDouble(lat), Convert.ToDouble(lng));
                    //pin.Tap += new EventHandler&lt;GestureEventArgs&gt;(pin_Tap);
                    //pin.Background = Colors.Cyan;
                    directions_button.Content = "Directions";
                    directions_button.HorizontalAlignment = HorizontalAlignment.Left;
                    directions_button.VerticalAlignment = VerticalAlignment.Bottom;
                    directions_button.Width = 130;
                    directions_button.Height = 70;
                    directions_button.FontSize = 15;
                    //place_thumbnail = System.Windows.Media.(@"" + child_elements.Element("icon").Value);
                    //place_thumbnail.Source = new BitmapImage(new Uri(child_elements.Element("icon").Value, UriKind.Relative));
                    pin_grid.Width = 350;
                    pin_grid.Height = 150;
                    pin.Content = pin_grid;





For more of my code please let me know

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.