Oto metoda, której używam. By the way dla lepszego doświadczenia użytkownika i dla spójności sake rozważ użycie słów "usuń" i "anuluj" zamiast "potwierdzić" lub "przerwać".
public static MessagePromptResult Show(string messageBoxText, string caption, string button1, string button2)
{
int? returned = null;
using (var mre = new System.Threading.ManualResetEvent(false))
{
string[] buttons;
if (button2 == null)
buttons = new string[] { button1 };
else
buttons = new string[] { button1, button2 };
Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox(
caption,
messageBoxText,
buttons,
0, // can choose which button has the focus
Microsoft.Xna.Framework.GamerServices.MessageBoxIcon.None, // can play sounds
result =>
{
returned = Microsoft.Xna.Framework.GamerServices.Guide.EndShowMessageBox(result);
mre.Set(); // could have done it all without blocking
}, null);
mre.WaitOne();
}
if (!returned.HasValue)
return MessagePromptResult.None;
else if (returned == 0)
return MessagePromptResult.Button1;
else if (returned == 1)
return MessagePromptResult.Button2;
else
return MessagePromptResult.None;
}
Będziesz musiał dodać odniesienie do Microsoft.Xna.Framework.GamerServices do swojego projektu.
możliwe duplikat [WP7 dialogowym Alert] (http://stackoverflow.com/questions/ 4475602/wp7-alert-dialog) –