I have an OnClick event for my Pushpins as below.
void BusStop1061_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Buses from this station: City Link");
}
I would like to pass the bustop number to another page and to the int “PassedVariable”
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
string site = "http://www.sourceDomain?stop=" + PassedVariable;
webBrowser1.Navigate(new Uri(site, UriKind.Absolute));
}
I was thinking of creating a constant int on the Page one, then passing it to page 2 using urimapping, but it doesn’t seem to work and I figured someone might have a better option
I have had a look at similar posts, but they dont quite answer my question.
There are multiple ways to achieve this.
One way, is to create a BustopNumber property in the App.xaml.cs class, a set it in one page, and access it else where.
This is my preferred approach, although you have to guard against the case where the value isn’t set or invalid.
Another approach is to pass it in as a query string parameter, similar to what you are doing in your code snippet above. In the navigated to page, you can access the query string parameter via the
NavigationContextobject and look for by name.Edit to add:
Obviously there are issues with encapsulation, as this is essentially a hack for global, but if used carefully, can offer a quick and easy way to share information across multiple pages.