【发布时间】:2013-08-07 03:14:06
【问题描述】:
我有两个页面(MainPage 和 page1)。当用户在 page1 中时,如果用户按返回键,应弹出以下消息:“您确定要退出吗?”
因此,如果用户按下 OK,那么它应该导航到另一个页面,如果用户按下 Cancel,它应该停留在同一页面。这是我的代码:
这段代码是用Page1.Xaml编写的:
Protected override void OnBackKeyPrss(System.ComponentModel.CancelEventArgs e)
{
MessageBoxResult res = MessageBox.show("Are you sure that you want to exit?",
"", MessageBoxButton.OkCancel);
if(res==MessageBoxResult.OK)
{
App.Navigate("/mainpage.xaml");
}
else
{
//enter code here
}
}
但是,当我按下取消时,它仍在导航到 mainpage.xaml。我该如何解决这个问题?
【问题讨论】:
标签: c# windows-phone-7 windows-phone-8