[英]MessageBox never appears?
This is the code i use for exiting the app, 这是我用于退出应用的代码,
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
MessageBoxResult m = MessageBox.Show("Are you sure, Do you want to exit this application", "Exit Warning", MessageBoxButton.OKCancel);
if (m == MessageBoxResult.OK)
{
e.Cancel = false;
//MessageBox.Show("Working ON Exiting the app!");
if (NavigationService.CanGoBack)
{
while (NavigationService.RemoveBackEntry() != null)
{
NavigationService.RemoveBackEntry();
}
}
}
}
The problem is that message box never appears and the value of m
is taken as Cancel
. 问题是消息框永远不会出现,并且
m
的值被视为Cancel
。 What could be the problem? 可能是什么问题呢?
Using 运用
MessageBoxResult m = MessageBox.Show("Are you sure, Do you want to exit this application", "Exit Warning", MessageBoxButton.OKCancel);
will not be a wise decision, because when you keep it idle (without pressing ok or cancel) for sometime your application will exit automatically. 这将不是一个明智的决定,因为当您将其闲置(不按OK或Cancel)一段时间后,您的应用程序将自动退出。
Pls avoid this technique!! 请避免这种技术!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.