문제

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??

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top