2013-03-04 42 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)檢索數據。

相關問題