Windows-8.1

What Is a Universal Windows Platform (UWP) App?

The concept of a common application architecture was first introduced in Windows 8 as the Windows Runtime. Windows Runtime (WinRT) was an evolution of the Windows app model, intended to be a common application architecture. When Windows Phone 8.1 became available, the Windows Runtime was aligned between Windows Phone 8.1 and Windows. This enabled developers to create Universal Windows 8 apps that target both Windows and Windows Phone, using a shared codebase. This article introduces you to the Universal Windows Platform.

Introduction

Windows 10 introduces the Universal Windows Platform (UWP), which further evolves the Windows Runtime model and brings it to the Windows 10 unified core. As part of the core, the Universal Windows Platform now provides a common app platform available on every device that runs Windows 10.

Apps that target the Universal Windows Platform can call not only the WinRT APIs that are common to all devices but also APIs (including Win32 and .NET APIs) that are specific to the device family the app is running on.

The Universal Windows Platform provides a guaranteed core API layer across devices. This means you can create a single app package that can be installed on a wide range of devices.

1. Device Families

Windows 8.1 and Windows Phone 8.1 apps target an operating system (OS), Windows or Windows Phone. With Windows 10, an app no longer targets an operating system. Instead, an app targets one or more device families.

A device family identifies the APIs, system characteristics, and behaviors that you can expect across devices within the device family. It also determines the set of devices on which your app can be installed from the Store.

The decision which device family (or families) your app will target determines:

  • the set of APIs that your app can assume to be present when it runs.
  • the set of API calls that are safe only inside conditional statements. To isolate sections of code that are platform-specific, use the #ifdef directive.
  • the set of devices on which your app can be installed from the Store.

Here are some considerations to help you decide which device family to target:

  • Target the universal device family to reach the maximum range of devices.
  • Choose to target your app at one of the child families if it is specialized for, for example, a desktop PC or Xbox.
  • Target two (or more) child device families instead of targeting the universal device family.
  • In some cases, you may want your app to run everywhere except on devices with a particular version of a particular device family.

By default, Microsoft Visual Studio specifies Windows.Universal as the target device family in the app package manifest. To specify the device families for your app, manually configure the TargetDeviceFamily element in the Package.appxmanifest file.

2. User Interface and Universal Input

Windows helps you target your user interface to multiple devices with the following features:

Universal Controls and Layout Panels

Windows 10 includes new controls, such as the calendar and split view. Controls have been updated to work well on larger screens, adapt themselves based on the device’s screen resolution, and work well with multiple input types, such as keyboard, mouse, touch, pen, and controllers, such as the Xbox controller.

To help you adapt the user interface of an app based on the amount of available screen space, Windows 10 introduces adaptive panels and design states.

The new RelativePanel implements a style of layout that is defined by the relationships between its child elements. It is intended for use in creating app layouts that can adapt to changes in screen resolution.

Visual State Triggers

Your app’s user interface may need to adapt to changes in window size. Adaptive visual states allow you to change the visual state in response to changes in the size of the window.

State triggers define a threshold at which a visual state is activated, which then sets layout properties appropriate for the window size that triggered the state change. Here is the XAML for the visual state triggers described above.

Windows 10 introduces an evolution of the existing scaling model. In addition to scaling vector content, there is a unified set of scale factors that provides a consistent size for user interface elements across a variety of screen sizes and display resolutions.

You can build a universal Windows app using universal controls that handle various inputs, such as a mouse, keyboard, touch, pen, and controller (such as the Xbox controller).

3. Writing Code

Your programming language options for your Windows 10 project in Visual Studio include Visual C++, C#, Visual Basic, and JavaScript. For C# and Visual Basic, you can use XAML for a full-fidelity, native user interface experience.

For Visual C++, you can choose to draw with either or use XAML. For JavaScript, your presentation layer will be HTML. Let’s look at these different cases.

Whenever you want to call an API, you’ll need to know whether the API is implemented by the device family that your app is targeting. If you want to call just a small number of APIs, you could use the ApiInformation.IsTypePresent method like this.

A UWP app or Windows Runtime Component is written in C++/CX has access to the Win32 APIs that are part of the UWP. These Win32 APIs are implemented by all Windows 10 device families. Windowsapp.lib is an umbrella lib that provides the exports for the UWP APIs. Linking to Windowsapp.lib will add to your app dependencies on DLLs that are present on all Windows 10 device families.

4. User Experience

A UWP app allows you to take advantage of the unique capabilities of the device on which it is running. It provides a set of built-in features and universal building blocks that make it much easier to create a great user experience for multiple devices.

You can still have one app package that runs on all devices by checking what device family your app is running on before calling an extension API. Here are some of the features that you get when you create a UWP app:

  • When your app runs on a Windows-powered device, the system uses an algorithm to normalize the way controls, fonts, and other UI elements display on the screen. This scaling algorithm takes into account viewing distance and screen density to optimize for perceived size.
  • Although you can design for specific input devices, apps use an input system that uses “smart” interactions. That means that you can design around a click interaction without having to know whether the click comes from an actual mouse click or the tap of a finger.
  • The UWP provides a set of universal controls that are guaranteed to work well on all Windows-powered devices. These controls are input-aware and deploy with the proper set of input affordances, event states, and overall functionality for each device family.
  • Your UWP app automatically gets a default set of styles which can be customized to give your app a personal touch, or can be replaced completely to create a unique visual experience.

Conclusion

Here are some of the characteristics that make UWP apps on Windows 10 different:

  • You target device families, not an OS. A device family identifies the APIs, system characteristics, and behaviors that you can expect across devices within the device family. It also determines the set of devices on which your app can be installed from the store.
  • All UWP apps are distributed as a .appx package, providing a trustworthy installation mechanism and ensures that the apps can be deployed and updated seamlessly.
  • There’s one store for all devices. You can submit and manage all your apps for Windows devices in one place.
  • The UWP core APIs are the same for all Windows device families. App using only the core APIs will run on any Windows 10 device.
  • Extension SDKs are specialized APIs for each device family, which can be used if the app is intended for a particular device family.
  • UI elements use effective pixels, so they automatically adapt themselves based on the number of screen pixels available on the device.

Vivek Maskara

I am pursuing BTech in Software Engineering from Delhi Technological University. I develop apps, create websites and blog about my app experiences.

  • Can i have the same AdMediator element have different size based on the device family?

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close