Udostępnij za pośrednictwem


Getting started with Windows 10 preview - universal app platform

 

The Windows 10 Developer Preview provides an early look at the tools and features coming with the Windows universal app platform (UAP).

 

To get started, we need to first sign up for Windows Insider Program

OS and development tools, SDK preview edition can be downloaded after signing up for Windows Insider Program 

 

1. Download and install Win10 preview ISO on your development and test machine

Public download latest version till date – 10049.

Please note that this version of OS will expire and it’s not complete version. You may need to keep the preview version updated until its release

 

2. Download and install Visual Studio 2015 CTP 6

 

3. Download and install Visual Studio 2015 Tools for Windows 10 Preview

 

Understanding universal apps for Windows 8.1 and Windows 10 Preview UAP

 

Universal Apps targeting Windows 8.1 devices:

 

When we target Windows 8.1 devices, we have one solution with three separate projects and two builds, one build each for Windows Phone and Windows Client. Universal Apps in Windows 8.1 platforms means that we can share our code across these two projects (apps targeting Windows Phone and apps targeting Windows Client).

 

To differentiate platform-specific code in shared (third) project, we use #ifdef directive. We use predefined constants WINDOWS_APP and WINDOWS_PHONE_APP in C#

#if WINDOWS_APP

               //Windows platform related code

#endif

#if WINDOWS_PHONE_APP

                //Windows Phone platform related code

#endif

 

In C++, for Phone-specific code, we use WINAPI_FAMILY_PHONE_APP directive. For example:

#if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP

        //Windows Phone platform related code

#else

         //Windows platform related code

#endif

 

 

Universal Apps targeting Windows 10 devices:

 

When we target Windows 10 devices, we have one solution with one project (by default) with one build (app) that runs across all Windows 10 devices. Universal Apps Platform (UAP) in Windows 10 means that virtually everything is shared on all devices.

We need to design pages using adaptive UI controls and new layout panels so that they render properly, on all devices, used to view them.

 

UAP provides a guaranteed API layer and adaptive UI controls based on Windows Core. Windows Core is the new refactored common core of Windows with common set of APIs and infrastructure. Windows Core helps in true binary compatibility across different platforms. With the guaranteed API layer, various devices add their own unique APIs so that we (developers) can create custom, tailored app using unique features of these devices.

 

UAP is a collection of contracts and versions. It defines the platform that is running your app and acts as a broker between the app and the operating systems. With UAP, we (developers) will need to shift from targeting OS to UAP.

To targeting platforms with the UAP, we just need to update TargetPlatform in the manifest.

For example:

<TargetPlaform Name="Microsoft.Universal" minVersion="3.0.0.0" maxVersionTested="4.5.0.0" />

 

 
   

clip_image001[18]

Figure depicts Windows Core and universal device family inheriting properties from respective device families.

Extensions SDK allows device specific APIs to be accessible in UAP based app. For example, UAP will not be able to provide access to types like BackButtonPressed in targeting Windows Phone platform, if we do not add Windows Phone extension SDK as a reference in our app project.

 

Unlike Universal Apps in Windows 8.1 platform mentioned above, in UAP Win 10 app, the easiest way to look for certain API or device is by using Foundation Metadata namespace. ApiInformation static class helps in identifying current platform(s), supported classes, contracts, APIs, etc.

 

// Cache the value if it is going to be used more than once.

bool isHardwareButtonsAPIPresent = Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons");

 

 

    if (isHardwareButtonsAPIPresent)

    {

        Windows.Phone.UI.Input.HardwareButtons.CameraPressed +=

            HardwareButtons_CameraPressed;

    }

 

There is no need for conditional compilation, as the HardwareButtons class and the Backpressed event is included in the UAP, even though the runtime type does not exist in the current device.

We can also test the presence of individual members by using IsEventPresent, IsMethodPresent, IsPropertyPresent, etc, instead of IsTypePresent. The set of APIs within a device family is further divided into subdivisions called API contracts. We can use ApiInformation.IsApiContractPresent method to check if an API contract is present.

 

And here’s a very cool MVA course to dig deeper with Windows 10 developer preview:

https://www.microsoftvirtualacademy.com/training-courses/a-developers-guide-to-windows-10-preview

 

 

 

PS: The information provided in this post relates to Windows 10 preview build and details may change with Windows 10 release.

Disclaimer: This post is provided "AS IS" with no warranties and confer no rights.