Question

I navigate from a page to another. I know how to Transfer some data between These pages:

"Calling Page":

 NavigationService.Navigate(new Uri("/Views/ViewerPage.xaml?image=" + mImageID, UriKind.Relative));

"Called Page":

 NavigationContext.QueryString.TryGetValue("image", out mImageURL)

But how can I Transfer more complex data?

 List<tring> mList = new List<string>;
 mList.Add("test-1");
 mList.Add("test-2");

I want to transfer now the complete list `mList' to the called page. Any indeas how to handle this?

Was it helpful?

Solution

In the first page do the following:

PhoneApplicationService.Current.State["param"] = mList;
NavigationService.Navigate(new Uri("/PhonePageOne.xaml", UriKind.Relative));

And in the second retrieve the parameter:

List<string> p = PhoneApplicationService.Current.State["param"] as List<string>;

The PhoneApplicationService.State dictionary is a temporary storage location which persists until your app is deactivated.

Other option could be to declare a static member in, for example, App.xaml.cs and use it to save thoe object from one page an to retreive from the second one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top