Tuesday, 7 June 2011

Ways of passing data between WP7 pages

The book Programming Windows Phone 7 (MS Press) introduced 4 ways:
  1. add a public propery on App class to retain the data during current lifecycle;
  2. add a public propery on the target page, and then in the prev page's OnNavigatedFrom event set the value of the property for the next page;
  3. use the property State from the application's current PhoneApplicationService instance, which is a type of generic dictionary. But the object been stored has to be serializable (the reason is when app goes to deactivated it will serialize the objects to isolated storage);
  4. isolate storage. BUT obviously it is not wise to frequently access isolate storage during application running. Here is a great article of compairing the performance of using isolate storage http://blogs.claritycon.com/kevinmarshall/2010/11/03/wp7-serialization-comparison/

No comments: