It sounds like you are not saving the application state before it is tombstoned. There are 4 events that are fired for preserving application state:
These are related to completely closing and reopening the application (eg: Phone restart)
- Application_Launching
- Application_Closing
These are related to tombstoning (task switching)
- Application_Activated
- Application_Deactivated
It sounds like what you need is the second one relating to activating / deactivating. These methods are placed in the Applications *.cs file and allow you to preserve and reinstate the ViewModel when tombstoning.
This is an example:
private readonly string ModelKey = "Key";
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
PhoneApplicationService.Current.State[ModelKey] = ViewModel;
}
private void Application_Activated(object sender, ActivatedEventArgs e)
{
if (PhoneApplicationService.Current.State.ContainsKey(ModelKey))
{
ViewModel = PhoneApplicationService.Current.State[ModelKey] as FeedViewModel;
RootFrame.DataContext = ViewModel;
}
}