2013-03-04 78 views
2

我正在使用Windows Phone。当我的应用程序停用并进入后台时,我想检测OnNavigatedFrom事件上的应用程序停用,以便在应用程序进入后台时实现一些逻辑。我怎样才能做到这一点?????Windows Phone应用程序停用检测页面

回答

0

使用下列方法(在App.xaml.cs文件中)时,应用程序被激活或去激活来执行逻辑:

// Code to execute when the application is launching (eg, from Start) 
// This code will not execute when the application is reactivated 
private void Application_Launching(object sender, LaunchingEventArgs e) 
{ 

} 

// 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) 
{ 

} 

// 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) 
{ 

} 

// Code to execute when the application is closing (eg, user hit Back) 
// This code will not execute when the application is deactivated 
private void Application_Closing(object sender, ClosingEventArgs e) 
{ 

} 
1

我找到了解决自己。将处理程序附加到您导航的页面上的PhoneApplicationService.Current.Deactivated事件。

1

您可以保存从APP事件或页面事件中停用的时间,并将其存储在IsolatedStorage中,然后在您的应用重新激活时(OnNavigatedTo)检索数据。

相关问题