Question

I have a listbox in my WP7 app, and I would like to keep/save listbox inserted items when I reload the application. I tried this, but it not work:

    protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
    {
        this.SaveState(e);
    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        this.RestoreState();
    }

What should I do??

Was it helpful?

Solution

In tombstoning you should look at storing application data in the PhoneApplicationService.State or IsolatedStorage.ApplicationSettings (depending on the size of the data).

The App.xaml.cs file already contains four methods to help you know when you application is 'Launching' (raised when the user initially launches the application), 'Activated' (raised when the application is dormant or tombstoned and the user navigates back to the application), 'Deactivated' (whenever the user navigates forward away from the application. Although applications are typically made dormant after they are deactivated, there is no way to know at this point whether the application will be tombstoned or terminated after this event) and 'Closing' (when the user uses the Back button to navigate backwards past the first page of your application. After this event, your application is terminated)

For more info check out : How to: Preserve and Restore Application State for Windows Phone

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