Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Getting started with Windows Universal

DZone's Guide to

Getting started with Windows Universal

·
Free Resource

Introduction:

With Windows 10, Microsoft presents a new platform with VS2015 CTP update i.e., a focus on single app that can run across all Windows Devices.

UAP:

  UAP stands for Universal App Platform which helps one to develop a app that have single application which runs all Windows device like Mobile Devices, Personal computers, XBox, Holo Lens, Surface Hubs and Internet of Thing IoT devices

The evolution to Window 10.

Currently Windows 10 targeted to Unified Core and app platform that make the app can run all windows devices. Here the picture clearly explained the evolution to windows 10.

·  The Xbox 360 was converged to OS Kernel in Xbox one then now targeted to Windows 10

·  And Windows Phone (Silverlight) was converged to OS Kernel in Window Phone 8 (Silverlight) and Supports WinRT in 8.1 through which now targeted to Windows 10

·  Winsow8 originated with OS Kernel and now targeted to Windows 10

The Main goal of the Windows 10 is target a version of the UAP not the operation system

Brief details of UAP

Target Platform Name

Microsoft.Universal

Operation System

Windows 10

IDE

Visual Studio 2015 CTP 6 / RC

Core platform

WinRT

A glance on UAP

The UAP support available from VS2015 CTP with Windows 10 Tool and that enables develop application for all Windows device including Xbox, Hololens and Surface hub. Here, It need only one project that can run across the devices (Universal App creates two, one for Windows and another for Windows Phone with a shared projects) and there is absolutely no needed for Shared project.

Create a new UAP Project

After installing Visual Studio 2015 CTP with Window10 Technical Preview Tools in a Windows 10 Machine, Windows 10 Template can available in VS2015 project Template in New Project Dialog

1.  An UAP project can create using New Project dialog can open through Ctrl+Shift+N keys

2.  Currently 4 project templates available with Windows 10. Are

  1. Blank Application (UAP)
  2. Class Library (UAP)
  3. Window  RunTime Component(UAP)
  4. Unit Test App (UAP)

3.  Now Create Blank Application UAP by Template -> Window 10 -> Blank Application (UAP) with suitable Name (for example, UAPApp) of the project in required physical location.

4.  Now the solution explorer contains a solution with single project. Here there is no "Shared" project created as like as old Universal project template

5.  Open MainPage.XAML and use the following code 

6.  In designer, can able to switch multiple view as per the windows device layout to check the current design in both horizontal and vertical orientation 

The single application can run according to the device

UAP Extensions and SDKs

In previous we need to have separated Binaries and SDK for individual platform across the devices. For example for an API. Phone HardwareButton Which is available in Windows Phone but other many windows devices.

In previous we have checked this cases with Compilation Code Constants as per the following code snippet

#if WINDOWS_PHONE_APP

Windows.Phone.UI.Input.HardwareButtons.BackPressed += this.HardwareButtons.BackPressed;

#endif

But it not needed to Windows 10, For example if we need to access Hardware Buttons in Windows Phone or a remote control in Xbox, that can control by SDKs through

·  Extends the UAP

·  Targets Specific Platforms

·  Updates at a separate cadence

Here instead of using Condition Compilation constants we can make use of contracts for example “Windows.Foundation.Metadata.ApiInformation” that contains following interfaces

·  IsApiContractPresent

·  IsEnumNameValuePresent

·  IsEventPresent

·  IsMethodPresent

·  IsPropertyPresent

·  IsTypePresent

·  IsWritablePropertyPresent

For Example HArdwareButtton availability can be check through following code

If(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(“Windows.Phone.UI.Input.HardwareButtons”))

{

Windows.Phone.UI.Input.HardwareButtons.BackPressed += this.HardwareButtons.BackPressed;

}

UAP API Contracts and Versions

UAP included with 4 API Contracts as follows (Preview)

·  Windows.Foundation.FoundationContract

·  Windows.Foundation.UniversalApiContract

·  Windows.Foundation.RemoveFromThisBadContract

·  Windows.Networking.Connectivity.WwanContract  

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}