June 27, 2017

Develop for Windows 10 – (2) What to Know about UWP

fromto

 

In this post, I am trying to summarized what we have learned about UWP during Build 2015. I will only list the items, leave out details. In the future post I will try to get into some details if I can. After reading it, you will probably say, ah, that’s not much. I think that impression is correct. Even though there has been many sessions in the Build Conference, the changes are profound, but for developers, there isn’t a lot to learn. That’s a great job from Microsoft.

 

Adaptive

The most important thing in UWP is concept of adaptive programming. Keep this in mind: your application will potentially run on many different type of devices (from PC to Xbox, HoloLens), different size of screens, and different versions of UWP. Even though you have the option to write separate code for each case, but you mostly wouldn’t.

In order to deal with all situations, you need: 1) Runtime code detection to deal with different device types (families) since different device type may implement different set of APIs. 2) Set MinVersion, MaxTestedVersion and get latest SDK to cover most UWP versions, try to support cutting edge features while still keep backward compatibility. 3) Use controls like SplitView, RelativePanel and Pivot to adapt to screen sizes. Also can use VisualState in XAML or in the code behind to further adapt to screen changes.

 

Extension SDKs

Extension SDKs bring in APIs that are not commonly implemented in UWP. There are desktop Extension SDKs, Mobile Extension SDKs, etc. All you have to do is reference them in your Visual Studio projects. Call the APIs after runtime API detection.

 

API Contracts

API Contracts is the way UWP groups functionalities. By putting a collection of APIs together, you don’t have to detect each one of them separately, because they are either implemented in full or none. Each API Contract can relate to certain type of devices.

 

New in XMAL

SplitView, RelativePanel and Pivot are mentioned above. Many know that Pivot control is the most used in Windows Phone, now it is implemented in UWP, only it becomes tabs in large screen automatically. Others are: ContentDialog (popup dialog), AutoSuggestBox, Map Control, PerspectiveTransform3D (transform control in 3D space: rotations and parallax), Windowing (can customize background, titlebar, etc.), Ink Canvas, Drag and Drop, WebView.

AppBar is not new, but if used properly, it can replace SplitView, make the app more visually compelling. I will look into this later.

 

Application Life Cycle

As a developer, we need to be aware that application states: not running -> running suspended -> not running. What trigger them. What to do before application is suspended.

Related topic is background task, how to start one and how to manage it.

 

I think that’s almost all (there are other things: notification, live tiles, advertising, Cortana, but they are not something you will certainly use). As you can see, every subtitles above except for the last one are actually part of “Adaptive”. So, I’d like to simplify it a little by saying “UWP means Adaptive”.