我正在开发 wp7 上的应用。
我希望在用户退出应用程序(按后退按钮)时提示确认对话框。
这可能吗?
欢迎任何评论
最佳答案
请处理应用页面中的BackKeyPress按钮来处理返回键的按下。
在 Page.xaml 文件中的元素中添加这段代码
BackKeyPress="PhoneApplicationPage_BackKeyPress"
应该是这样的
<phone:PhoneApplicationPage BackKeyPress="PhoneApplicationPage_BackKeyPress"
..//other attributes .. >
在事件处理程序中,您编写如下代码
private void PhoneApplicationPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
{
MessageBoxResult mb = MessageBox.Show("You want exit the page", "Alert", MessageBoxButton.OKCancel);
if( mb != MessageBoxResult.OK)
{
e.Cancel = true;
}
}
关于windows-phone-7 - 退出应用程序时提示确认对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8975822/