Click here to Skip to main content
15,894,362 members
Articles / Desktop Programming / XAML

Attached Command for Windows 8 Metro Style in C#

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
27 Jan 2012Ms-PL2 min read 52.8K   1.5K   19  
Attached Command for Windows 8 Metro Style in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;

namespace Application3
{
    partial class MainPage
    {
        public MainPage()
        {
            InitializeComponent();
            this.DataContext = new VM();
        }
    }

    public class VM
    {
        public DelegateCommand TestCommand
        {
            get
            {
                return new DelegateCommand(p =>
                {
                    MessageDialog messageDialog = new MessageDialog("Testing dialog");
                    var op = messageDialog.ShowAsync();
                    op.Start();
                });
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions