[UWP]单键MessageDialog [英] [UWP]Single button MessageDialog
问题描述
我的App.xml.cs中只有一个按钮就有一个MessageDialog
我希望从其他页面使用它。
有几种方法似乎有效,但由于异步和任务有微妙之处是特定的一种吗?
I have a MessageDialog with just a single button in my App.xml.cs
I wish to use it from other pages.
Several approaches seem to work but as there are subtleties with async and Tasks is a particular one correct?
推荐答案
大多数开发人员(和开发人员工具)会建议静态版本,但从异步/任务的角度来看,两者之间没有技术差异。请记住在通话中使用 await - 无论实施如何。否则,打开对话框的
代码将在对话框打开时继续。因此,对静态方法的调用应该是:
most developers (and developer tools) will advice the Static version, but from an async/task perspective there is no technical difference between the two. Please remember to use await in the call - regardless of the implementation. Otherwise the code that opens the dialog continues while the dialog is open. Therefor the call to the static method should be:
await App.mymessagebox("A message");
这篇关于[UWP]单键MessageDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!