Windows Phone - 返回键

Windows Phone应用程序需要符合一些列的Guidelines,其中"返回键"是一个容易出问题的地方。

 

<<UI Design and Intercation Guide for Windows Phone 7>> v2.0中这样描述:

 

 

The hardware Back Button is used to navigate back on pages (screens) within an application or between applications. The application allows the framework to perform the operation when the button is pressed. Also, the Back Button can be used to close menus, dialogs, navigate to a previous page, exit a search operation, or even switch applications. However, the principal usage is to navigate from the current page to the previous page.

See the Navigation, Frames, and Pages topic for more information about the page navigation model in Windows Phone 7.

When a user navigates back out of the root page of an application, the application will terminate.

The Back Button will not work as a backspace key to delete text input.

 

 

See the Navigation, Frames and Pages topic for additional guidance.

Developers should only implement Back Button behaviors that navigate back or dismiss context menus or modal dialog boxes. All other implementations are prohibited.

 

SDK 7.0/7.1 文档中的相关描述是:

 

The hardware Back button is used to go back within an application or between applications. Also, the Back button can close an on-screen keyboard, menus, dialogs, navigate to a previous page, exit a search operation, or even switch applications. However, the principal usage is to move from a current screen to the previous screen.

 

总之,"返回键"只能用于返回上一页面。只是在有键盘、context菜单或弹出窗口时,这个返回操作是关闭键盘、取消context菜单或者弹出窗口。

 

如果页面中有弹出窗口,按"返回键"应取消弹出窗口,而不是退回到上一页面,Page类提供了可重载的OnBackKeyProcess方法,可供处理此逻辑:

 

 

 

 

有些情况下需要提醒用户是否要退出当前页面(返回上一页面),例如提醒用户保存当前页。此时可重载OnBackKeyProcess方法如下:

 

 

 

用户第一次按下"返回键"时弹出提示窗口,此时,用户再次按下"返回键"时,返回上一页面。

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值