
Code snippets for a message box in Windows Store apps:
Simple Messagebox
public async void ShowMessage(string message)
{
MessageDialog msg= new MessageDialog(message);
await msg.ShowAsync();
}
A more complex example from Corrado's Blogs
private async void OnMessage(object sender, RoutedEventArgs e)
{
MessageDialog dialog = new MessageDialog("Hello WinRT");
UICommandInvokedHandler cmdHandler = new UICommandInvokedHandler(cmd =>
{
Debug.WriteLine("id:{0} label:{1}", cmd.Id, cmd.Label);
});
UICommand cmd1 = new UICommand("Cmd1", cmdHandler, 1);
UICommand cmd2 = new UICommand("Cmd2", cmdHandler, 2);
UICommand cmd3 = new UICommand("Cmd3", (cmd) =>
{
Debug.WriteLine("Command3 done!");
}, 3);
dialog.Commands.Add(cmd1);
dialog.Commands.Add(cmd2);
dialog.Commands.Add(cmd3);
dialog.DefaultCommandIndex = 1;
await dialog.ShowAsync();
Debug.WriteLine("Dialog closed");
}