.NET Metro App Development by Calling WinRT APIs of Windows 8

WinRT APIs for windows 8” in .Net will not replace or compete Win32.  You can write client and server applications using .NET, including “WPF” (Windows Presentation Foundation) plus “Silverlight“. You can write server applications and client in C++, including Win32 and “MFC” (Microsoft Foundation Classes). However, if you choose to believe in the way “Metro“, you can write Windows Metro applications in .NET with C++  or with JavaScript, with a consistent set of APIs exposed through WinRT.

.NET  Metro App Development by Calling WinRT APIs of Windows 8

In this article (Practically) you will find that the  “How to use  WinRT APIs of the standard .NET”.  But  Primarily,

1-Understand the Basics from My Previous Article Asynchronous API Based (Element of Metro UI Windows 8)- “WinRT”.

2-You will need the full “Visual Studio 2011” installed in the Windows Dev Preview 8.

First, create a new WPF project. Then go to add references and press “Search”. Go to “C: \ Program Files (x86) \Windows Kits \8.0\Windows metadata”

Be sure to select “All Files”. Note that VS11 gives you an error if you try to add more than one at a time..so you have to add each one individually. We will show a rapid application lists the devices, so let’s take a couple of namespace named “windows.foundation.winmd” and “windows.devices.enumeration”.

let us see a little view-model:

First we’ll make a little view model:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.Enumeration;
using Windows.Foundation;

namespace WpfApplication1
    public class MainWindowViewModel
        : INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;

        public MainWindowViewModel()
            var operation = DeviceInformation.FindAllAsync();
            operation.Completed = CompletedFindDevices;

        public IEnumerable  Devices
            get { return this.devices; }
            private set
                if (this.devices == value)

                this.devices = value;
                OnPropertyChanged ("Devices");

        private IEnumerable<DeviceInformation> devices;

        private void OnPropertyChanged (string propertyName)
            var changed = PropertyChanged;
            if (changed != null)
                changed (this, new PropertyChangedEventArgs (propertyName));

        private void CompletedFindDevices (IAsyncOperation<DeviceInformationCollection> asyncInfo)
            Devices = asyncInfo.GetResults();

And then the Xaml (don’t forget to hook up the datacontext to the view model in your code behind):

<Window x:Class="WpfApplication1.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <ListBox ItemsSource="{Binding Devices}">
                <TextBlock Text="{Binding Name}" />

And then the “Xaml”  [Remember to hook up the “data context” to the view model in your “code behind”]

Out put Looks like..

.NET Metro App Development by Calling WinRT APIs of Windows 8 -output

This does not embody the chance of implementing the contracts of many platforms..however it is a beginning.

Important to note:

1- Apparently, the alternative is true .. additional or less. you’ll be able to sit down with your existing one. web and use them in an application WinRT. It remains to be seen or heard if they’ll be allowed on the App Store, however it works in apply. The Important is that you just will sit down with the missing items of the BCL, thus if you would like a bloke over there (System.Net.EndPoint for example), you’re still out of luck.
2: The usefulness of the certification application doesn’t WinRT unsupported applications known as. web API thus, they’ll run, however don’t get within the store.

Spread the love

Comments are closed.