Search code examples
c#windows-phone-7windows-phone-8windows-phonetombstoning

PhoneApplicationService.Current.State vs IsolatedStorageSettings windows phone


I need to pass a large set of data from one page to another. I have two choices as far as I know, PhoneApplicationService and IsolatedStorageSettings.

PhoneApplicationService creates a lot of delay in when passed between pages. So, I used IsolatedStorageSettings but I am getting some abnormal object creation while removing an item from IsolatedStorageSettings.

which is the best to deal with large complex objects?

What is actually happening while removing items from IsolatedStorageSettings ?

Thanks

EDIT: When I clear or remove an item from IsolatedStorageSettings, new objects for already stored keys are created.

sample code:

                if (IsolatedStorageSettings.ApplicationSettings.Remove("FormFields"))
                {
                    IsolatedStorageSettings.ApplicationSettings.Add("FormFields", app.response);                       
                }
                else
                {
                    IsolatedStorageSettings.ApplicationSettings.Add("FormFields", app.response);                      
                }

Solution

  • Why don't you just use the App class?

    public partial class App : Application
    {
        public YourDataObject ApplicationDataObject { get; set; }
    }
    

    You could use it in any page, for example setting values before jumping to the next page:

     (Application.Current as App).ApplicationDataObject = new YourDataObject();
    

    And retrieving values once you are in the right page:

    YourDataObject yourData = (Application.Current as  App).ApplicationDataObject;
    

    It is not beautiful but it is very simple and perhaps in your case it is the best solution.