Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MessageBox.Show for Windows Phone 7

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 :(

like image 701
Vic Avatar asked Jan 03 '11 17:01

Vic


3 Answers

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.

like image 118
Praetorian Avatar answered Nov 19 '22 19:11

Praetorian


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

like image 28
Phil Figgins Avatar answered Nov 19 '22 17:11

Phil Figgins


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

like image 1
rarev Avatar answered Nov 19 '22 17:11

rarev