处理后退按钮 Windows 8.1 通用应用程序
我正在将我的应用从 Windows Phone 8 Silverlight 更新到 Windows 8.1 RT(我认为这就是所谓的).
I'm updating my app from Windows Phone 8 Silverlight to Windows 8.1 RT (I think is called that).
我刚刚创建了我的第二页,当我转到并按下后退按钮时,它会退出我的应用程序,而不是返回第一页.
I've just created my second page and when i go to and press the back button it goes out of my app instead of going back to first page.
我不知道为什么会发生这种情况,默认行为会显示在最后一页吗?
I don't know why is this happening, default behaviour is going to last page right?
我找不到如何覆盖后退按钮事件以进行 Frame.GoBack()
调用.
I can't find how to override back button event to make a Frame.GoBack()
call.
这是一个开发预览错误还是我遗漏了什么?
Is this a dev preview bug or am I missing something?
放入第二页的构造函数中:(SecondPage.xaml.cs)
put into the constructor of the second page: (SecondPage.xaml.cs)
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
然后定义事件处理函数:
and then define the eventhandler function:
private void HardwareButtons_BackPressed( object sender, BackPressedEventArgs e )
{
Frame.GoBack();
e.Handled = true;
}