locked
messagebox equivalent RRS feed

  • Question

  • i can't find any MessageBox equivalent function in the new visual c# using metro, any body can show me how to display a message to the user, or where i can find a table of the equivalent functions ?

    thanks in advance for all the help.

    Sunday, December 25, 2011 4:09 AM

Answers

  • Here you go.

    MessageDialog msg=new MessageDialog("Message","Title");
    await msg.ShowAsync()
    


    Kind regards, HeToC. http://www.linkedin.com/in/hetoc
    • Proposed as answer by HeToC Monday, December 26, 2011 2:00 PM
    • Marked as answer by Bob_Bao Monday, January 2, 2012 9:39 AM
    Sunday, December 25, 2011 1:31 PM
  • Hi:

    A solution for that error would be append the "async" word to the method, this way:

    private async void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
    {
         Windows.UI.Popups.MessageDialog wMsg = new Windows.UI.Popups.MessageDialog("Esta es Una Prueba", "pruebita pues");
         await wMsg.ShowAsync();
    }

    This way, once you call the method it gets executed asyncronously, and you can continue with the execution.

    Hope this works for you.

     


    Roberto Luis Bisbé
    http://robertoluis.wordpress.com
    Microsoft Student Partner
    • Marked as answer by Bob_Bao Monday, January 2, 2012 9:39 AM
    Monday, December 26, 2011 8:51 AM

All replies

  • Here you go.

    MessageDialog msg=new MessageDialog("Message","Title");
    await msg.ShowAsync()
    


    Kind regards, HeToC. http://www.linkedin.com/in/hetoc
    • Proposed as answer by HeToC Monday, December 26, 2011 2:00 PM
    • Marked as answer by Bob_Bao Monday, January 2, 2012 9:39 AM
    Sunday, December 25, 2011 1:31 PM
  • i have put my code in the LayoutRoot_loaded function for testing the function, it looks like

     

    private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
    {
         Windows.UI.Popups.MessageDialog wMsg = new Windows.UI.Popups.MessageDialog("Esta es Una Prueba", "pruebita pues");
         await wMsg.ShowAsync();

     

    but i'm having this error code

    the 'await' operator can only be used when its containing method or lambda expression is marked with the 'async' modifier

     

    any ideas ?

    Monday, December 26, 2011 3:03 AM
  • Hi:

    A solution for that error would be append the "async" word to the method, this way:

    private async void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
    {
         Windows.UI.Popups.MessageDialog wMsg = new Windows.UI.Popups.MessageDialog("Esta es Una Prueba", "pruebita pues");
         await wMsg.ShowAsync();
    }

    This way, once you call the method it gets executed asyncronously, and you can continue with the execution.

    Hope this works for you.

     


    Roberto Luis Bisbé
    http://robertoluis.wordpress.com
    Microsoft Student Partner
    • Marked as answer by Bob_Bao Monday, January 2, 2012 9:39 AM
    Monday, December 26, 2011 8:51 AM
  • Hi,

    WinRT is mostly async, so you need to understand its basics. Here is a good quickstart for you.


    Kind regards, HeToC. http://www.linkedin.com/in/hetoc
    Monday, December 26, 2011 9:03 AM