问题
I'm aware that there are already questions questions asked regarding closing a MessageBox programmatically . But the solution to those questions is to use a timer.
I am trying to develop an NFC application, so when i create a MessageBox, it contains a message Please Tap Your NFC
. So technically, the Timer isn't helpful. I need a way to close or dispose a MessageBox.
Please advice.
回答1:
You can create a custom window yourself as described in the question you linked. However, instead of a timer you can and include a Hide
method which you can call once NFC connection event occurs.
Alternatively, you could get Coding4Fun toolkit and use MessagePrompt
class which already includes a Hide method.
回答2:
From lieska at MessageBox.Show in App Closing/Deactivated events
Register BackKeyPress event on RootFrame.
RootFrame.BackKeyPress += BackKeyPressed; private void BackKeyPressed(object sender, CancelEventArgs e) { var result = (MessageBox.Show("Do you want to exit XXXXX?", "Application Closing", MessageBoxButton.OKCancel)); if (result == MessageBoxResult.Cancel) { // Cancel default navigation e.Cancel = true; } }
来源:https://stackoverflow.com/questions/16848986/how-to-close-messagebox-programmatically-in-wp8