I have a problem with “re-init” MainWindow objects settings. I thought that OnNavigatedTo will call after suspending too and I have some code in MainWindow like:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
object.value = initValue;
}
But it wasn’t called after suspending. So how can do this after suspending?
If you use the default templates that come with VS2012, you’ll see following code in the App.xaml.cs file:
The possible values for ApplicationExecutionState are
So just add another if statement for
to execute the code you want to execute after a suspended state.
To restore a previous state in the pages itself, use the LoadState and SaveState methods that are defined on the LayoutAwarePage base class of each page (or implement your own state management). The templates that come with VS2012 (eg. the Grid application) already uses all these tricks for state management and are a good way to get started.