1

I want to create a 2nd-level page enabling the user to post-process an image captured before. To get that image to page 2, I want to pass is as some kind of parameter. But the only way I saw was to append it as a string to the URL and that doesn't sound to efficient.

Of course I know about serialisation, but take the Lima 1020 capturing in 38 megapixels: that's almost 500mb RAM and though I'm ot sure if a string can theoretically contian that much data, I seems terribly bad style.

So is there a clean ways to pass the data (by clean I mean: pass it as parameter, without using e. g. static classes)?

David Božjak
  • 16,887
  • 18
  • 67
  • 98
jalgames
  • 781
  • 4
  • 23
  • In some answers to similar questions you can find a way to do it by extending NavigationService - [like in this article](http://www.kunal-chowdhury.com/2013/10/passing-object-to-wp-navigation-service.html). – Romasz Mar 31 '14 at 20:56

3 Answers3

1

You can try:

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

and on other page we can get it like this.

var k = PhoneApplicationService.Current.State["yourparam"];

Ref. 1

deeiip
  • 3,319
  • 2
  • 22
  • 33
0

The easiest way to pass data between pages, is to have a static class or a singleton that will hold the data you want to be available across all your pages.

The other answer that suggests using the state dictionary is valid, but that might not be what you want. Using the state dictionary requires your data to be serializable, and sometimes this needs some unnecessary extra code. Plus, the state dictionary's main use is for preserving the state of the application when it is sent to the background or when it's tombstoned, so it isn't really made for passing parameters across pages (Read more here)

disklosr
  • 1,536
  • 17
  • 26
-1

There is another way Pass non-string parameters between pages on Windows Phone.

Alen Lee
  • 2,479
  • 2
  • 21
  • 30