WP7: pass parameter to new page?

In a Silverlight app for Windows Phone 7, I invoke a new page using

NavigationService.Navigate(new Uri("/View/SecondPage.xaml", UriKind.Relative)); 

Now I want to pass the parameters to a new page. I understand that a simple parameter can be passed using:

 NavigationService.Navigate(new Uri("/View/TilgungsratePage.xaml?id=4711", UriKind.Relative)); 

and read on the new page with

 protected override void OnNavigatedTo(Microsoft.Phone.Navigation.PhoneNavigationEventArgs e) { base.OnNavigatedTo(e); String id = NavigationContext.QueryString["id"]; } 

For simple parameters this is fine, but how do I pass the list?
Complex facilities?
Anything but simple meanings?

+23
parameter-passing windows-phone-7
Nov 10 '10 at
source share
5 answers

In his book Windows Phone 7 Programming (Chapter 6, Section 3, โ€œInterchange between Pagesโ€), Charles Petzold recommends properties in the App class (obtained from Application ). Each page has access to it through Application.Current . Also interesting is the PhoneApplicationService.Current.State dictionary. It is useful for the tomb. The entire chapter may be interesting to read.

+21
Nov 21 '10 at 11:23
source share
โ€” -

You should also look at the MVVM template and the messenger class.

Here are some links:

MVVM Overview

MVVM Foundation Messenger

Good SO question about MVVM Light messenger

MVVM Light Blog

+2
Nov 10 2018-10-10
source share

see how I implemented navigation in PhoneCore Framework: The framework for creating a WP7 application . Soon, I built a navigation service on top of WP7 navigation. It uses a custom page mapping and allows you to pass custom parameters to automatically view the model.

0
Jan 19 2018-12-12T00:
source share

Use global variables, create a new class for GlobalVariables:

 public static class GlobalVariables { public static string my_string = ""; public static int my_int = -1; } 

Then you can access the class of global variables for different pages:

 GlobalVariables.variable_name; 
0
May 01 '12 at 3:58
source share

You must save the object in IsolStorage.

Just serialize it in the Json.net library and save the line in IsolStorage. On the next page, you will get the string from IsolStorage and convert it back to the object you want using the json.net library!

-one
Feb 05 '12 at 15:30
source share



All Articles