Windows Phone 7 的 MessageBox.Show

发布于 2024-10-10 11:07:24 字数 312 浏览 0 评论 0原文

我需要一个 MessageBox.Show(),但具有扩展功能:Windows Phone 7 的内置消息框不会显示任意按钮,只是“确定”或“取消”,我还需要“YesNo”。我需要一个只有当用户单击按钮时才会返回的 Show 方法。我尝试将自己的消息框制作为弹出窗口。问题是它与 WP7 中 UI 线程中的所有内容一样都是异步的,并且我无法阻止 UI 线程,因为 UI 线程还负责处理按钮单击事件。我看到了 WP7 的 ChildWindow 示例,但这也是异步的,我必须有一个仅在用户单击时返回的 Show() 方法。有什么建议吗?某种 DoEvents() 可以帮助我很多,但 WP7 中没有这样的方法:(

I need a MessageBox.Show(), but with an extended functionality: the built-in messagebox for Windows Phone 7 won't show arbitrary buttons, just OK or cancel, I need for example YesNo as well. I need a Show method that will return only when the user clicks on a button. I tried to make my own messagebox as popup. The problem is that it is asynchronous as everything in the UI-thread in WP7, and I cannot block the UI-thread because the UI-thread is responsible for handling the button click events as well. I saw a ChildWindow example for WP7, but that was also asynchronous, I must have a Show() method that returns only when the user clicks. Any suggestions? Some kind of DoEvents() could help me a lot, but there is no such method in WP7 :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

黯然 2024-10-17 11:07:24

您可以使用 XNA 的 Guide.BeginShowMessageBox() 来显示带有自定义消息框按钮。 这里有关如何使用它的教程。

请注意,MessageBoxIcon 参数在 WP7 上不是选择图标,而是选择显示消息框时的通知声音。

编辑:
糟糕,在我发布之前没有阅读您的同步要求。也许您可以设置一个标志来停止您想要阻止运行的任何内容,并在用户做出选择后重置它。

You can use XNA's Guide.BeginShowMessageBox() to display a MessageBox with custom buttons. Here's a tutorial on how to use it.

Note that the MessageBoxIcon parameter does not select an icon on WP7, instead it selects the notification sound when the message box is displayed.

EDIT:
Oops, didn't read your synchronous requirement before I posted. Maybe you can set a flag to stop whatever you want to prevent from running, and reset it once the user has made a selection.

千纸鹤 2024-10-17 11:07:24

我在寻找类似的东西时发现了这一点,但最终只是使用内置的消息框。它肯定会让您能够拥有自定义按钮。

Windows Phone 7 自定义消息框

I found this when looking for something similar, but wound up just using the built in messagebox. It would certainly give you the ability to have custom buttons.

Windows Phone 7 Custom Message Box

忘东忘西忘不掉你 2024-10-17 11:07:24

使用包含您想要的所有内容的画布。然后只需使用可见性属性将其弹出..

Use a Canvas that has everything you want on it. Then just use the visibility property to pop it up..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文