相当于"OnBackKeyPress"是什么意思? [英] What is the equivalent to "OnBackKeyPress"

查看:126
本文介绍了相当于"OnBackKeyPress"是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows Phone 8.0中,我使用它来处理后退按钮:

In Windows Phone 8.0 I used this to handle the back button:

protected override void OnBackKeyPress(CancelEventArgs e)
{
    base.OnBackKeyPress(e);        
}

此事件在页面"控件上不存在.如何处理WP 8.1中的后退按钮?

This Event does not exists on the "Page" control. How can I handle a click on the back button in WP 8.1?

推荐答案

看看如果您将Basic Page添加到您的项目中,则VS会将一个NavigationHelper类添加到您的项目中,这有助于通过App进行导航,您还可以在源代码中看到它正在订阅Windows.Phone.UI.Input.HardwareButtons.BackPressed.

If you add a Basic Page to your project then VS will add a NavigationHelper class to your project which helps with Navigating thru your App, you can also see in the source code that it is subscribing to Windows.Phone.UI.Input.HardwareButtons.BackPressed.

如果您想扩展处理后退"按钮(管理事件处理程序队列等),可以此答案-那里的方法将有助于防止向后导航(如果不需要)并添加更多行为.

In case you want to extend handling the Back Button (managing Eventhandler queue and so on) you may take a look at this answer - the method there will help to prevent backward navigation (if you don't need it) and add some more behaviours.

这篇关于相当于"OnBackKeyPress"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆