Universal Apps MessageBox: "The name 'MessageBox' does not exist in the current context"

I want to use MessageBox for showing download errors in my WP8.1 app.

I added:

using System.Windows;

but when I type:

MessageBox.Show("");

I get error:

"The name 'MessageBox' does not exist in the current context"

In Object Browser I found that such class should exist and in "Project->Add reference... ->Assemblies->Framework" is shown that all assemblies are referenced.

Do I miss something? Or is there another way how to show something like messagebox?


Solution 1:

For Universal Apps, the new APIs require you to use await MessageDialog().ShowAsync() (in Windows.UI.Popups) to bring it into line with Win 8.1.

var dialog = new MessageDialog("Your message here");
await dialog.ShowAsync();

Solution 2:

Just wanted to add to ZombieSheep's answer: also, customization is quite simple

        var dialog = new MessageDialog("Are you sure?");
        dialog.Title = "Really?";
        dialog.Commands.Add(new UICommand { Label = "Ok", Id = 0 });
        dialog.Commands.Add(new UICommand { Label = "Cancel", Id = 1 });
        var res = await dialog.ShowAsync();

        if ((int)res.Id == 0)
        { *** }