TechNet
Products
IT Resources
Downloads
Training
Support
Products
Windows
Windows Server
System Center
Microsoft Edge
Office
Office 365
Exchange Server
SQL Server
SharePoint Products
Skype for Business
See all products »
Resources
Channel 9 Video
Evaluation Center
Learning Resources
Microsoft Tech Companion App
Microsoft Technical Communities
Microsoft Virtual Academy
Script Center
Server and Tools Blogs
TechNet Blogs
TechNet Flash Newsletter
TechNet Gallery
TechNet Library
TechNet Magazine
TechNet Wiki
Windows Sysinternals
Virtual Labs
Solutions
Networking
Cloud and Datacenter
Security
Virtualization
Updates
Service Packs
Security Bulletins
Windows Update
Trials
Windows Server 2016
System Center 2016
Windows 10 Enterprise
SQL Server 2016
See all trials »
Related Sites
Microsoft Download Center
Microsoft Evaluation Center
Drivers
Windows Sysinternals
TechNet Gallery
Training
Expert-led, virtual classes
Training Catalog
Class Locator
Microsoft Virtual Academy
Free Windows Server 2012 courses
Free Windows 8 courses
SQL Server training
Microsoft Official Courses On-Demand
Certifications
Certification overview
Special offers
MCSE Cloud Platform and Infrastructure
MCSE: Mobility
MCSE: Data Management and Analytics
MCSE Productivity
Other resources
Microsoft Events
Exam Replay
Born To Learn blog
Find technical communities in your area
Azure training
Official Practice Tests
Support options
For business
For developers
For IT professionals
For technical support
Support offerings
More support
Microsoft Premier Online
TechNet Forums
MSDN Forums
Security Bulletins & Advisories
Not an IT pro?
Microsoft Customer Support
Microsoft Community Forums
Sign in
Home
Library
Wiki
Learn
Gallery
Downloads
Support
Forums
Blogs
Resources For IT Professionals
United States (English)
Россия (Pусский)
中国(简体中文)
Brasil (Português)
Skip to locale bar
Post an article
Translate this page
Powered by
Microsoft® Translator
Wikis - Page Details
First published by
Shubham_Saxena
(eMicrosoft Partne)
When:
17 Nov 2012 11:58 AM
Last revision by
Maheshkumar S Tiwari
When:
17 Sep 2013 9:45 AM
Revisions:
2
Comments:
1
Options
Subscribe to Article (RSS)
Share this
Can You Improve This Article?
Positively!
Click Sign In to add the tip, solution, correction or comment that will help other users.
Report inappropriate content using
these instructions
.
Wiki
>
TechNet Articles
>
Message Dialog in Metro Style App
Message Dialog in Metro Style App
Article
History
Message Dialog in Metro Style App
After the release of Windows 8 i.e. 26th October developers have gone crazy about developing Metro style applications. I have been developing for Windows previously also and MessageBox was the most used control, but in Metro style apps I didn't find it, so this is simply an article to guide you through the use of message boxes in Metro style apps which are called Popups here. The message box here is fully user-defined, we can add the commands to the message box and also add an action with it. Here is a walkthrough of doing that.
The first step is to create a new Metro Style Blank App Project.
A blank project will open in front of you. We will add our code into "MainPage.xaml.cs". In the following project I will add the message box under the "OnNavigatedTo" event so that as soon as the Application is opened the message box will appear.
Now we will add a namespace for the message box in Metro style apps:
using Windows.UI.Popups;
Now its time to enter our actual code. Here is a code snippet:
In the first line a new object for the MessageDialog is created which is saved in a "var md". MessageDialog has an argument which is the message box text which is displayed when the message box appears:
var md = new MessageDialog("Are you sure you want to exit");
The second line adds a new command to the message box i.e. "Yes"; the new UICommand creates an object for a new command and the new UICommandInvokedHandler adds the action to the corresponding command; here the action we have added is: Application.Current.Exit(); this closes the application.
md.Commands.Add(new UICommand("Yes", (UICommandInvokedHandler) =>
{
Application.Current.Exit();
}));
The third line adds another command i.e. "No". This will cause nothing to the application and the application will continue.
md.Commands.Add(new UICommand("No"));
Debug the app to see the result:
en-US
,
has code
,
has image
,
message box in metro style apps
,
Message Dialog
,
Metro Style App
,
Metro Style Blank App Project
,
Windows 8
,
windows metro style
[Edit tags]
Leave a Comment
Please add 2 and 6 and type the answer here:
Post
Wiki - Revision Comment List(Revision Comment)
Sort by:
Published Date
|
Most Recent
|
Most Useful
Comments
Maheshkumar S Tiwari
17 Sep 2013 9:45 AM
Maheshkumar S Tiwari edited Original. Comment: Added tags
Edit
Page 1 of 1 (1 items)
Wikis - Comment List
Sort by:
Published Date
|
Most Recent
|
Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
Posted by
Maheshkumar S Tiwari
on
17 Sep 2013 9:45 AM
Maheshkumar S Tiwari edited Original. Comment: Added tags
Edit
Page 1 of 1 (1 items)