Windows Phone应用程序在页面上的停用检测



我在Windows Phone上工作。当我的应用程序停用并进入后台时,我想检测OnNavigatedFrom事件上的应用程序停用,以便我可以实现一些逻辑,如果应用程序进入后台。我该怎么做?????

我自己找到了解决办法。

将处理程序附加到所导航页面的PhoneApplicationService.Current.Deactivated事件。

你可以节省时间,当它从APP事件或页面事件停用,并存储在IsolatedStorage,然后检索数据,当你的应用程序重新激活(OnNavigatedTo)。

使用以下方法(在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)
{
}

最新更新