Passing data object between XAML pages

Go To StackoverFlow.com

1

I haven't found any useful answer, or should I say "any answer" that how can I pass data objects between the pages in WP7?

PAGE1

IEnumerable<dictParts> Parts = LoadParts();

How can I pass Parts to PAGE2?

2012-04-04 17:36
by wafers


2

See also How to pass a value between Silverlight pages for WP7?

You have a couple of options:

  • Serialize the data and pass it on the querystring of the Navigate() request.
  • Store the data in a global variable that is accessible from both pages (like the MVVM pattern).
2012-04-04 18:09
by gbanfill
thanks, I used global variable - wafers 2012-04-04 18:50
It can be done by using global variable

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

Then you access the Global Variables class like this: GlobalVariables.variable_name e.g. GlobalVariables.my_string;

Ref: http://forums.create.msdn.com/forums/p/66396/573232.asp - wafers 2012-04-04 18:54

Be sure you are careful about memory leaking (i.e. - you may want to nullify the object when you go back from the page. - Shahar Prish 2012-04-04 20:24
Ads