4

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.

Community
  • 1
  • 1
Jieqin
  • 588
  • 5
  • 21

2 Answers2

3

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.

Alaa Masoud
  • 7,085
  • 3
  • 39
  • 57
0

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;
        }
}
Community
  • 1
  • 1