Ads Top

How to show a message dialog box in VS 2013


MessageDialog is one of the important feature in VS you can show notifications, warnings or you can use it in try catch blocks. In this tutorial we will learn how a message dialog works.

First of all make new windows store project.


In MainPage.xaml write the following code
<Button Name="MessageButton"
                Content="Click to show message dialog"
                Click="message_dialog_click"/>
Now put your cursor on click and press F12 press mouse right click and click “Go to Defination”



A buttons click event has been generated in MainPage.xaml.cs. Write “MessageDialog” and you will see a red squeezing  line under it plus there is small blue box under M this means you have include it’s class just simply right click on it a popup menu will appear and fron second option “Resolve” select “Windows.UI.Popups;” now you resolve it complete the code and the press F5.

MessageDialog msg = new MessageDialog("This is a Message Dialog");
            msg.ShowAsync();




Now press F5 and press the button you will see a dialog box.


No comments:

Powered by Blogger.