December 15, 2017

Develop for Windows 10 Q&A – (5) Adaptive Code

ja

 

This Q&A is related to video #8 (Adaptive code) and #18 (Navigation) in Jerry Nixon and Andy Wigley’s A Developer’s Guide for Windows 10.

Q. How UWP Is Architected to Allow Adaptive Coding?
A. Adaptive is a common scene in almost all aspects of UWP. The main part in UWP that allows for adapting to different type of devices is the concept of extension SDK. When create a Windows Universal Project in Visual Studio 2015, the common UWP part of the SDK is in. However if you need to access APIs that are special to certain device family (Desktop, Mobile, etc.), you have to add reference to corresponding extension SDKs.

Q. How to Do to Deal with UWP Versioning?
A. UWP and extension SDK versions are defined in project manifest file as TargetDeviceFamily. Version compatibility info is stored in the built XAP package. Can be retrieved by the store and Windows. There are three key elements:

Name = "Windows.Universal"
minVersion = "1.0.0.1" - base version, app won't install if device UWP version is lower than that.

maxVersionTested = "10.0.0.1" - guaranteed version to run on.

Q. How to Do Runtime Test?
A. The following two picture illustrate how to detect API existence at runtime, and how to make decision based on that.

test
test1

 

Q. What’s New in Windows Resizing?
A. Because of the difficulty of different device handling devices differently. Say, a page on a phone won’t resize as on desktop. UWP helps developers by introducing,

TryResizeView(new size(with, height)) - It works on all device, if you device won't allow resizing like in a phone, but you can still call it, just return false, won't crash.

SetPerferredMinSize(new size(with, height)) Again it can be called without worry about device type. The OS will deal with it for you.Navigation 1:00

 

Q. What’s New about Windowing?
A. Apps used to be full screen in 8.0, windowed starts from 8.1. Now there is new feature in that you can create another window under the same application.

CoreApplication.CreateNewView()

 

Q. How Does Navigation Work in Windows 10?
A.  Each application has a frame, it’s like the main windows. Inside it, there are pages. We have been doing Frame.Navigate() to switch between pages. There isn’t much change, only enhanced it to pass not only strings, but also objects. Provided the object is serializable.

var nav.Navigate = app.NavigationService;
nav.Navigate(typeof(Views.Page2), "params");

Note: Template 10 was mentioned many times. It sounds like an advance template that will come with release of Viusal Studion 2015.