I don’t know why I feel compelled to write this blog today, but I have a terrible sore throat from giving two talks yesterday in a noisy room.  So it might the two baby aspirins I took, hope the FDA doesn’t require that there be prescriptions for baby aspirins.

Anyway, MessageDialogs are pretty easy to use, and if you find the right article in MSDN you might even find that you are able to implement it in your code. 

So here is the super simple code I came up with and note that it violates all of the rules of design, good software design and so forth.  It does not use asynchronous, you can get that in the other samples, it just throws the MessageDialog and you can use it for interim trouble shooting if you wish.

First create XAML page, here is the code I used:

<Page
    x:Class="MessageDialogExample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MessageDialogExample"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Button Content="Button"
                HorizontalAlignment="Left" VerticalAlignment="Top"
                RenderTransformOrigin="3.45,3.026" Margin="376,110,0,0"
                Tapped="Message2Event" >
        </Button>
    </Grid>
< /Page>

Here is the header file:

#pragma once

#include "MainPage.g.h"

namespace MessageDialogExample
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public ref class MainPage sealed
    {
    public:
        MainPage();

    private:
        void Message2Event(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
    };
}

Here is the event that you add to the blank template source file:

using namespace Windows::UI::Popups;

void MessageDialogExample::MainPage::Message2Event(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
{
    // Create the message dialog and set its content
    MessageDialog^ msg = ref new MessageDialog("No internet connection has been found.");
   
    UICommand^ customCommandButton = ref new UICommand("Why oh why am I using C++?");
       
    msg->Commands->Append(customCommandButton);
    // Show the message dialog
    msg->ShowAsync();

}