WP8.1后退按钮退出应用程序 [英] WP8.1 back button quits the app
本文介绍了WP8.1后退按钮退出应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我上一次针对Windows Phone开发的是版本8.现在,我使用的是8.1.也许这是MS的一项新功能,但是当我按下手机上的后退"按钮时,无论我对应用程序有多深入,应用程序都会最小化.这真烦人!有什么我可以做的吗?
The last time I developed against Windows Phone, it was with version 8. Now I'm making use of 8.1. Maybe this is a new feature from MS, but when I press the back button on the phone, regardless of how deep I'm into the app, the app minimizes. This is seriously annoying! Is there anything that I can do?
非常感谢!
推荐答案
是的,这是Windows Phne 8.1非SL应用程序中的正常行为.
以下是在您的App.xaml.cs
文件中实现的解决方法:
Yes, this is the normal behaviour in Windows Phne 8.1 non-SL apps.
Here a workaround to implement in your App.xaml.cs
file:
public App()
{
this.InitializeComponent();
HardwareButtons.BackPressed += HardwareButtons_BackPressed;
}
void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame != null && rootFrame.CanGoBack)
{
e.Handled = true;
rootFrame.GoBack();
}
}
这篇关于WP8.1后退按钮退出应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文