When I wrote the 31 Days of Windows Phone, I neglected to talk about how to pass data between pages when navigating. For the most part, I pass strings as query string variables, and for more complex structures, like objects, I store them in IsolatedStorage, and retrieve them on the next page. In my articles, however, I never talked about query strings, and how they work.
To pass a query string, just add it on like you do in ASP.NET.
private void MapButton_Click(object sender, EventArgs e) { NavigationService.Navigate(new Uri("/Map.xaml?m=" + RoomText.Text, UriKind.Relative)); }
In your OnNavigatedTo event, you can grab the query string information. Here’s what the code looks like, if I were passing a query string variable named “m”:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); if (NavigationContext.QueryString.ContainsKey("m")) { map = NavigationContext.QueryString["m"]; } }
I seem to talk about the Marketplace quite often here, but I think that’s because with each new submission, I learn something new. Today’s Marketplace tidbit involves releasing an update to your application. You’ll go to your app’s screen at http://create.msdn.com, and choose “Submit application update.”
An important thing to remember is that as soon as you make this choice, you won’t have access to your application description, category, subcategory, icons, screenshots, or anything else you provided the first time. IT ALL GOES AWAY. So, make sure you copy and paste that information from this screen BEFORE you make this choice. Otherwise, you’ll have to hunt it down elsewhere, or find it from your old files (you saved those, right?)
Leave a Reply