Search code examples
c#windows-phone-8.1win-universal-app

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

  • 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();