之后在 App.xaml.cs 中处理相关的事件 ( Application life cycle 相关的事件在 App.xaml.cs 中都可以找到 )
// Code to execute when the application is activated (brought to foreground) // This code will not execute when the application is first launched private void Application_Activated(object sender, ActivatedEventArgs e) { object tmp = 0; if (PhoneApplicationService.Current.State.TryGetValue("Score", out tmp)) { App.HighScore = (int)tmp; } else App.HighScore = 0; } // Code to execute when the application is deactivated (sent to background) // This code will not execute when the application is closing private void Application_Deactivated(object sender, DeactivatedEventArgs e) { PhoneApplicationService.Current.State["Score"] = App.HighScore; }