Im not sure im going about this the right way or not, so hopefully somebody can help me.
Im trying to use a var in a method, which is contained in a different method. As expected, I get the error: The name 'Title1' does not exist in the current context .
first im reading an xml file then populating bing maps with pushpins. One of the variables is the tite of each xml item, I need to use the "Title1" var on my method below.
Here is the code:
public void OnOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
var document = XDocument.Load(e.Result);
if (document.Root == null)
return;
var xmlns = XNamespace.Get("http://www.blahblah.com");
var events = from ev in document.Descendants("item")
select new
{
Latitude = Convert.ToDouble(ev.Element(xmlns + "Point").Element(xmlns + "lat").Value),
Longitude = Convert.ToDouble(ev.Element(xmlns + "Point").Element(xmlns + "long").Value),
Title = (ev.Element("title").Value),
Description = (ev.Element("description").Value),
Link = (ev.Element("link").Value),
};
QuakeLayer.Children.Clear();
foreach (var ev in events)
{
var accentBrush = (Brush)Application.Current.Resources["PhoneAccentBrush"];
var Title1 = (ev.Title);
var pin = new Pushpin
{
Location = new GeoCoordinate
{
Latitude = ev.Latitude,
Longitude = ev.Longitude
},
Background = accentBrush,
Content = Title1
};
QuakeLayer.AddChild(pin, pin.Location);
}
}
public void Pushpin_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
NavigationService.Navigate(new Uri("/blahblah.xaml?info=" + Title1, UriKind.Relative));
}