Getting Started With Windows 10 Universal App Platform (UAP)

Introduction

With Windows 10, Microsoft presents a new platform with VS2015 CTP update. It is a focus on single apps that can run across all Windows devices.

UAP

UAP stands for Universal App Platform that helps one to develop an app that runs all Windows devices, like Mobile Devices, Personal Computers, XBoxes, Holo Lens, Surface Hubs and Internet of Things (IoT) devices.

The evolution to Window 10

Currently Windows 10 is targeted to the Unified Core and an app platform that allows the app to run on all Windows devices. Here the picture clearly explains the evolution to Windows 10.

  • The Xbox 360 was converged to OS Kernel in Xbox one and then os 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 though that is now targeted to Windows 10
  • Windows 8 originated with the OS Kernel and is now targeted to Windows 10

The Main goal of Windows 10 is to target a version of the UAP, not the operating 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 is available from VS2015 CTP with the Windows 10 Tool and that enables development of applications for all Windows devices, 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 project) and there is absolutely no need for a Shared project.

Don't have any default Code Compilation constants.

A single designer but can switch to a different layout depending on all the available Windows devices in design time.

Create a new UAP Project

After installing Visual Studio 2015 CTP with Windows 10 Technical Preview Tools in a Windows 10 Machine. A Windows 10 Template is available in the VS2015 project template in the New Project dialog.

  1. A UAP project can created using the New Project dialog can be opened using Ctrl+Shift+N keys
  2. Currently 4 project templates are available with Windows 10. They are:
    1. Blank Application (UAP)
    2. Class Library (UAP)
    3. Window RunTime Component (UAP)
    4. Unit Test App (UAP)
  3. Now create a Blank Application UAP by Template -> Windows 10 -> Blank Application (UAP) with suitable name (for example, UAPApp) of the project in the required physical location.
  4. Now the Solution Explorer contains a solution with a single project. Here there is no "Shared" project created as in an old Universal project template
  5. Open MainPage.XAML and use the following code
  6. In the designer, you can switch to one of multiple views depending on the Windows device layout to check the current design in both horizontal and vertical orientation
  7. The single application can run depending on the device as per the following screenshot.

In Desktop

In Phone

UAP Extensions and SDKs

In the previous whatever we need to have separated binaries and SDK for individual platforms across the devices. For example for an API. The phone HardwareButton is available in a Windows Phone and in many other Windows devices.

In the previous something we have checked that the cases with Compilation Code Constants as per the following code snippet are something.

  1. #if WINDOWS_PHONE_APP  
  2. Windows.Phone.UI.Input.HardwareButtons.BackPressed += this.HardwareButtons.BackPressed;  
  3. #endif  

But it does not need Windows 10. For example, if we need to access Hardware Buttons in a Windows Phone or a remote control in an Xbox then that can be controlled by SDKs through:

  • Extends the UAP
  • Targets Specific Platforms
  • Updates at a separate cadence

Here, instead of using Conditional Compilation constants we can use contracts, for example “Windows.Foundation.Metadata.ApiInformation” that contains the following interfaces:

  • IsApiContractPresent
  • IsEnumNameValuePresent
  • IsEventPresent
  • IsMethodPresent
  • IsPropertyPresent
  • IsTypePresent
  • IsWritablePropertyPresent

For example, HArdwareButtton availability can be checked using the following code:

  1. If(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(“Windows.Phone.UI.Input.HardwareButtons”))  
  2. {  
  3.    Windows.Phone.UI.Input.HardwareButtons.BackPressed += this.HardwareButtons.BackPressed;  
  4. }  
UAP API Contracts and Versions

UAP is included with 4 API Contracts as follows (Preview):

  • Windows.Foundation.FoundationContract
  • Windows.Foundation.UniversalApiContract
  • Windows.Foundation.RemoveFromThisBadContract
  • Windows.Networking.Connectivity.WwanContract

Up Next
    Ebook Download
    View all
    Learn
    View all