How To Close MessageBox Programmatically in WP8?

萝らか妹 提交于 2020-01-24 05:43:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!