Or “What you can use to target 1+ billion devices with one application”
Further resources including videos are indicated at the bottom of this post.
Windows 10 is scheduled for its first official public release today, Wed Jul 29 2015, on desktops, laptops, 2-in-1s and large tablets. More so than with any previous Windows release, millions of users either already have the bits (‘Windows Insiders’ – anyone who decided to sign up for the free program and install bits on their system) or are registered to upgrade (as regular consumer or small business users with Windows 7/8.1 users who signed up via the icon in the their taskbar).
In any case, anyone with a legitimate copy of Windows 7 or 8.1 (with the latest updates) can update to Windows 10 for FREE within the next 1 year. Enterprise users have to pay to upgrade but may be covered by an existing Software Assurance arrangement. MSDN should also carry various editions applicable to the MSDN subscriber level, subject to MSDN licensing terms.
Starting a little later in the year, we’ll see a roll out of Windows 10 for other device families, including Windows 10 on 55” and 80” Microsoft Surface Hub devices, Windows 10 Mobile on phones and small tablets, Windows Holographic on HoloLens and further Windows 10 IoT Core releases for IoT devices like Raspberry PI 2.
In any case, Microsoft is targeting 1 billion + users for Windows 10 on many device families.
Here are 10 things you should know about to help you build an application that can run on those devices.
#0 The new user features
Because this post is for developers, let’s start with a bonus #0 item. Aside from being free for many individuals Windows 10 brings these new features which are of value to consumers and business users.
Xbox One streaming
Gamers and households can be entertained in harmony. If you have an Xbox One you can stream the audio and video experience to the Xbox app on your Windows 10 PC. You control the game by connecting an Xbox One controller (via USB or via a wireless adapter available later in the year) to the PC. This allows you to enjoy your Xbox One experience in another room or to just free up your larger screen for use by someone else with another source (e.g. TV).
Cortana
This personal agent (previously available on Windows Phone 8.1) runs on all Windows 10 devices, bringing voice-(or typed-text) initiated personal information guidance, reminder setup and execution, deep topic app launching, simple task processing and querying over the world’s data via Bing.
Windowed Applications
All Windows devices run Universal Windows Platform apps. All the editions released today – for the desktop/laptop device family – also run legacy Windows desktop applications that you ran on Windows XP/Vista/7/ 8/8.1. Best of all they all now run on the desktop in windows with all the overlapping, moving and resizing one would expect. New snapping features make it easy to neatly divide up each monitor to show multiple applications side by side (or in quarters).
Start menu
It’s back, launching from the start button, combining the best of previous start menu design with tiles introduced in Windows 8.1. I would personally like to see live tiles in a taller and animated task bar where they’d always be visible, since the tiles in the start menu are only visible when the start menu is visible.
Notification Center
For an application to get a user’s attention immediately, the best alert is usually a toast notification. However, if the user is otherwise engaged or away from the device, they miss it. To avoid this and to have a central place for all notification for the user, Windows 10 has the new Notification Center (which premiered on Windows Phone). All toasts get added under the related app, listed in the notification center and an icon in the task tray tells the user that there are new un-dismissed items to be seen.
Edge
The name of the brand new modern-standards-based browser including a reading list, annotations, Cortana features and of course, lightning speed. LOB web application can still be launched in the older Internet Explorer.
Continuum
The killer feature of Windows 10. A continuum of Windows 10 experiences adapting to flexing keyboard, screen and mouse setups. When a 2-in-1 device (a device with detachable keyboard) goes into tablet mode (possibly automatically), window overlapping is temporarily suspended such that the user can either have one full-screen application window running or a snapped/divided arrangement of application windows. This is the behaviour we may have hoped for with Windows 8.1. Add to that Continuum for phones which will come later in the year with new devices, such that Windows 10 Mobile running on a phone or small tablet, can extend to an external monitor, keyboard or mouse, creating a PC in your pocket!
Windows as a service
Microsoft will continue to deliver a series of updates to Windows 10 devices at higher frequency than previously seen. Enterprises will have more control of this, but updates should still be more frequent than the older service pack model.
Now onto the regular 10…
#1 Universal Windows Platform (or UWP)
- With iOS, a developer can write 1 app to target two types of device.
- With Android, a developer can write 1 app to target all ‘supported’ devices, though this may take quite some testing to be sure.
- With Windows 8, a developer writes 2 apps (1 for PC and 1 for Phone with Universal Apps).
- With Windows 10, a developer writes 1 app against the Universal Windows Platform to target MANY different device families.
With Windows 10, there is ONE OS kernel (with different shells and features), ONE app platform (with extensions for additional device family features), ONE developer center to manage published apps, and ONE public store (as well as enterprise stores coming later).
The Universal Windows Platform can be built against using C# , VB or C++ languages using XAML and/or DirectX (plus another layer noted below) for UI, or alternatively using JavaScript + HTML/JS.
Additionally (phasing in over time), the following application types can be packaged like UWP apps (and can be updated to use UWP features!!) and placed in the store:
- The majority of existing Windows XP/Vista/7/8/8.1 desktop applications – on the desktop editions
- Live websites (running locally in the Edge ‘engine’ sourcing HTML/JS/CSS live from the Web)
- Android binaries – on the mobile editions
- iOS applications where all the Objective C source code is available and compiled using a special compiler
An app targeting the core Universal Windows Platform will run on ALL Windows 10 devices. To make this possible while not holding back on the capabilities of some device families (e.g. holographic), the platform supports Extension SDKs for device families.
Across all available APIs, the core Universal Windows Platform covers 85% which means you may never need an extension for most application.
The core Universal Windows Platform (and the extensions) can be frequently updated by Microsoft over time.
So, a developer of new apps for Windows 10 targets a specific version of the UWP. He/she does not target Windows 10 or some version of it. The developer can require the capabilities of one or more specific device family extensions or he/she can light up features depending on what’s discovered at runtime.
Runtime queries can check for specific types, methods, events or enumerations, or for a ‘contract’ which is a known collection of those things. A device family extension is a ‘uber’ contract.
So to have the best possible adaptation to the devices used at runtime, a developer should write adaptive code like this to conditionally only attempt to run code if the type/method/event/enum/contract is present at runtime.
For this example, the developer must add a reference to the Mobile Extension SDK so that the code will compile. Note that even though the CameraPressed event is not present on other device families, the application will still run and an exception will not occur so long as the if condition prevents the unsupported event from being used.
Note that a type/method/event/enum, will work on all the devices that report it as present (specifically or as part of a known API ‘contract’). The result of using it may vary however. For example, while methods for enumerating printers may be reported as present in the Universal Windows Platform (without any extension), it doesn’t mean that an Xbox will specifically support printers, so while the methods will not raise an exception under normal use, the result may always report 0 printers available, and the application should allow for this.
#2 Responsive Universal Controls
Since an app scan run on a wide variety of devices, the UI components must be responsive to their running environment in terms of space available and any method of interactivity. Fortunately the platform provides a set of universal controls than can be used on all devices. These controls respond to the size made available to them and to the method of interactivity used whether that be keyboard, mouse, touch pen, voice or gesture.
If you want to build your own control then you should build on available controls and/or use available APIs. To be responsive to space available your control may resize by scaling, clipping or wrapping with scrolling. It could also reflow content (e.g. having more or less columns given more or less width)
While it’s possible to know the physical pixel dimensions of a screen, developers should focus on effective pixels the system uses which account not only for pixel dimensions, but also for physical dimensions, dots per inch (DPI), likely distance from the user and user scaling settings (for are now per monitor in Windows 10).
#3 Adaptive Layout Features
When arranging controls in a view, or as a way of building a responsive control by using other inner controls, it is necessary to adapt to both the available effective pixel dimensions (for the window or outer control) and also the aspect ratio. This adaptation must occur whenever any of these things happen: the same code is runs on devices with different characteristics, the containing control/window is resized, the screen resolution is changed, the user scaling settings are changed, the window is moved to a different screen with different characteristics…
As available size changes, often resulting in a change of aspect ratio, it’s usually necessary to reposition controls in relation to each other.
The new RelativePanel makes this easier. Like other XAML panel controls, it has attached properties which are set on children to control their layout within the panel control. With RelativePanel these are declarations of relative position to another control or the panel.
Another common and more dramatic size-sensitive change, is the use of a split view where a content part (perhaps the core content or selected item detail) is always displayed, while the other part is a flexible pane (perhaps the menu or item selection list) – which may be open or closed and while open it may overlap or be inline (pushing the content part to the right). When closed it may just show icons. Many website now use this kind of design. The SplitView control comes with these capabilities. As with other XAML panel controls, SplitView and RelativePanel can be combined. For example, a scrolling list of items each using a RelativePanel may be in the content part of a SplitView so that information displayed in controls inside each list item can be arranged according to the horizontal space available.
The SplitView control and/or controls in a RelativePanel need to have their properties controlled as the environment changes. This can be done in code. It can also be done declaratively in XAML using an AdaptiveTrigger in a Visual State Manager. These allow a set of values to be set on properties on controls when a minimum screen width is reached. Several such value sets can be declared each for a different screen width break point. Additionally custom triggers can be created to effect property value assignment based on other changes.
If it becomes too much to make one view work on all devices with these kind of features, then it’s possible to undertake one of two approaches:
- Tailored Views – you can specify multiple XAML views specific to one or more device families (or write code to select a XAML file), all with the same code-behind file.
- Targeted apps – you can still create separate applications, that each target specific device families, but this is a last resort.
#4 Compiled Binding
Binding is an extremely powerful feature for XAML developers, particularly those using the MVVM architecture. However, memory usage and CPU time can be bogged down by intensive use of binding, especially with large datasets. The is largely due to the standard binding mechanism using reflection every time changes occur.
With Compiled Binding, at compile-time, each binding is checked and the change notification code is created in a type-safe way. This results in a little more initialization code, but no runtime reflection.
Developers opt-in by changing their binding syntax from “{Binding…}” to “{x:Bind …}” with the other … properties being very similar. Additionally, there is no use of DataContext. The data context is fixed to be the control in which the binding is taking place, i.e. the Window, Page, Control, etc. The type of this fixed context and its properties are known at compile time (whereas the type of a DataContext object is not).
If you want to attach a model then you can create a typed property on the Control (e.g. public MyViewModel ViewModel { get; set; } that you would access with “{x:Bind ViewModel.SomePropOfMyViewModel… }”) . There are some other supporting requirements for other scenarios, especially things like data templates in resource dictionaries.
Compiled Binding also enable binding to events! Note that while this can be used to fire a method from a button click event, similar to the use of ICommand, it does not support ICommand features like a command parameter or CanExecute querying (which you may achieve in other ways).
Note that both binding types can be used in one application.
#5 Composition APIs in the newly exposed Visual Layer
In Windows 8 you have the ability to mix together XAML and DirectX UI components. You may be using DirectX for performance or effects. In either case, you need to use C++ or a library like SharpDX to work with DirectX.
The work you do with XAML in an 8/8.1 app is talking with the DirectComposition layer underneath which then talks to DirectX, but you couldn’t access that middle layer. That changes with UWP apps. You can now program against the Composition APIs using C#/VB/etc.
This new and expanding layer provides effects and (parameterized) animations. And the best part? You can combine XAML with Composition APIs. Using the API you can access the visual objects and compositor that’s backing your XAML controls and work directly from there.
You can use the Composition APIs to do some things that you may have previously had to do with DirectX:
- Realize more complex animations and effects with very little code
- Animate a lot of different elements simultaneously
- Create Input-driven animations: like Sticky Headers, Parallax
- Have a lower level toolkit for building richer custom controls
The supported effects include:
- ArithmeticComposite
- Blend (20 different models)
- Saturation
- Composite (13 different models)
- ColourSource
- Transform2D
This new layer is still in development although present in the release build. You can get the team’s sample on GitHub – https://github.com/microsoft/composition
Follow the team on twitter with @WinComposition.
#6 Background tasks
The initial WinRT APIs for background tasks in Windows 8 were focused on tablet-style consumer devices where memory constraints, low CPU power and low battery capacity were key factors that influenced the API surface available for a ‘first release’.
With the the Universal Windows Platform running on a wide range of Windows 10 devices, it was important to cater to more powerful devices while also extending the ability to perform background work when resources are available.
In Windows 8.1, a WinRT app running in the foreground would suspend shortly after going into the background. On suspension the app has a few seconds to save state after which the threads would be frozen. The app could not continue work directly at this point and may be terminated (if the system needs more resources and subsequently restoring the user experience with the save state when re-launched). An app could register background tasks that could be triggered (whether or not the app is running or suspended) under various circumstances including remotely using notifications or special control channels. Background downloads could also be performed outside of foreground and background task execution. The tasks or cloud-triggered notifications could cause toast notifications which may bring the user to launch the app again.
With UWP apps on Windows 10 on the desktop editions (when not in tablet mode), regular suspension happens when an app is minimized (since there may be several ‘foreground’ apps running in windows).
With UWP apps, background tasks can now also run in the context of the foreground app.
Extended execution
With UWP apps on Windows 10, when an app is told that suspension is happening, it can request an extension (to perform non UI operations such as completing cloud/file-accessing operations, finish a computation, etc.). The system may revoke the extension with 1-second’s notice if it needs more resources, suspending the app.
Additionally, an application may request extension ‘privileges’ ahead of time in which case it never gets a suspend event, but still may be revoked.
Additional triggers
There are now additional triggers available to perform an app’s background tasks (whether running, suspended or not running). These include triggers for appointment/contact store changes, Bluetooth LE beacon events, device watcher/activity/threshold triggers, toast notification interactions, media events, a special trigger for incoming data on a socket that can be handled by the system while an app is not running, plus a special trigger that applications can perform to start up some background work (such as downloading and processing update data).
Opportunistic tasks
Background tasks usually only get about 30s to do their work which is usually more than enough. However, some apps may need to perform initialization and batch processing when the app is not running. Tasks triggered by the ApplicationTrigger (new in UWP), DeviceUseTrigger (new in UWP) and/or MaintenanceTrigger (from 8.x) can run as long as the system will allow when the ‘opportunity’ arises such as when the device has the resources.
#7 Inter-app communication
The app model on windows 8.x meant that applications where installed and executed largely in silos. This is great for maintaining system integrity, stability and cleanliness upon uninstallation.
Windows 8/8.1 WinRT apps are in fact still able to:
- Access the internet
- Access their own local storage area
- Use the Share charm to share with other applications
- Use printers
- Access special user folders, location, audio/video devices, Bluetooth devices & other connected devices with permission
- Launch apps using a Uri protocol, e.g. mailto:
With UWP apps on Windows 10 devices, you can now:
- Enumerate available apps by Uri protocol
- Launch specific apps by identifier
- Pass parameters to apps by Uri query parameters, name-value set or shared files
…and…
launch an app (optionally passing in parameters) that returns a name-value set or shared file(s)
- as a modal UI experience to get the result
- as an ‘invisible’ background task- i.e. local mini ‘app services’
In these last two scenarios, the target app may be acting as a (proprietary) proxy/cache/gateway/API around a local/remote service or repository with an open in/out parameter set.
#8 Cortana
Cortana has a host of built-in functionality to provide the services of a personalized assistant with text and voice I/O and can search using the knowledge of the Bing service to get other results.
If you register your application with Cortana, depending on how your make a request of the app, you can then:
- Launch the application, passing in a set of parameters.
- Have an interaction with the application’s features to perform a task via Cortana, without even launching the app. This allows you to quickly get things done with your voice without taking your hands off the productivity task on which you may already be focused.
Examples of patterns for requesting something from your app via Cortana are:
- <app> ‘add {product} to [my] {listname} wishlist’
- ‘add {product} to [my] {listname} wishlist’ using/on/with <app>
- ‘add {product} to the <app> {listname} wishlist’
When you request something of your app via Cortana which performs a task, you can subsequently:
- pick one of several choices if the application needs to disambiguate the input
- confirm an action once the application has all the information it needs
- see progress of the action being performed (which may involve access to the internet)
- get confirmation that the task has been performed
#9 Tiles, Toasts & Notifications
There were many tile templates for Windows 8/8.1 but the results may not always be what is expected. For example a template for a medium tile could be rendered to varying extents depending on the resolution, settings and scaling of the device used…
The old templates still work for UWP apps but there are now also 4 additional core adaptive templates – one for each of the four tile sizes supported on Windows 10 – small, medium, large and wide. These ‘templates’ are actually XML schemas for a document you build where you can describe what elements (including icons, text and images) that you’d like to display. This includes semantics for layouts including (all-or-nothing group contents) and wrapping hints. These adaptive tiles can therefore display content in a cleaner and more appropriate way (minimizing awkward clipping) irrespective of display circumstances.
When it comes to toasts for UWP apps, these now not only have the same adaptive XML feature as tiles, in a single ‘template’, but can include an image and interactive elements like a combobox, free text input and specific buttons.
A button on an interactive toast can be setup to perform one of the following when it’s clicked, passing along an identifier for the toast and the input data.
- Launch the related application.
- Perform a background task in the related application.
- Launch an application for a Uri protocol, e.g. mailto:
- Perform a system toast action like dismissing the toast or snoozing the application (to have it come back later).
So Cortana provides a way for you to perform a simple task or query via an application with minimal interruption to your current task, while an interactive toast allows an application (or remote service via an app) to quickly query the user and handle a response locally or in the cloud.
#10 Tooling
The premiere tooling experience for building Universal Windows Platform apps for all the existing and upcoming Windows 10 devices is Visual Studio 2015. You can get Visual Studio Community 2015 for FREE!! Visual Studio 2015 will install on Windows 7, Windows 8.1 & of course Windows 10. You can develop Windows 10 apps on 7 & 8.1 if you connect to and remotely debug on a Windows 10 device. Note that the XAML designer surface will not work on 7/8.1.
Developing for Windows 8/8.1 requires a periodic license update on your device via a Visual Studio 2013 edition. To deploy and test apps on a Windows 10 PC or mobile device you just have to click in the right place in settings!
In Visual Studio 2015 you’ll find some great improvements to help build UWP apps on Windows 10.
- XAML language service – provides an improved foundation using Roslyn which will lead to additional features later on.
- XAML editing features – XAML regions (like code regions) and Peek (into code while in XAML)
- UI Debugging – Display the live XAML tree, inspection of properties including where values are coming from and live editing of properties!!!
- Blend for Visual Studio – New theme, solution explorer from Visual Studio, Save/Load windows layout, fully keyboard accessible, auto reloading after VS-Blend switch
- Profiling tools – Profile combinations of CPU, Memory, Timeline, Network & more in UWA (and WPF!) apps
The .NET Native tools chain is now part of building Universal Windows Platform apps in Visual Studio (Release builds) and in the cloud! This means that you supply MSIL code to the store and the .NET Native compiler is used in the cloud to compile the apps for x86, x64 & ARM, ready for download to devices.
.NET Native compiled code can result in code starting 50% faster and average memory usage being 14% less!
Conclusion
There are many reasons for consumers and enterprises to quickly adopt Windows 10, adding to that 1 billion device target. I’ve shown you 10 developer topics that you can leverage to further your development of apps for Windows 10.
Further Resources
Find…
- The contents of this blog post as a 1-hour webcast video on Microsoft’s Channel9 – https://channel9.msdn.com/events/MVP-Virtual-Conference/MVP-Virtual-Conference-Americas-2015/Dev2-10-New-Things-for-Developers-on-Windows-10
- The contents of this blog post as a 3-hour developer readiness webcast video on Microsoft’s Channel9 – https://channel9.msdn.com/events/MVP-Virtual-Conference/Windows-10-Developer-Readiness-Powered-by-MVPs/Canada
- More about developing for Windows 10 – https://dev.windows.com/
- More in Canada – http://blogs.msdn.com/b/cdndevs/
- Launch events for Windows 10- http://blogs.windows.com/bloggingwindows/2015/07/20/join-microsoft-stores-to-celebrate-windows-10-with-special-events-guest-appearances-workshops-and-more/
- Microsoft Channel9 video recordings of Build 2015 conference sessions under http://channel9.msdn.com/Events/Build/2015/ with the session IDs indicated below
App Model 2-617, 3-733, 3-790
Inter-app communication 3-765
Background Tasks 3-626
Shell 2-762, 3-779, 684
Cortana 2-691, 3-716
Composition 2-672, 3-737
New for XAML 2-629
Layout 2-679
Binding 3-635
Visual Studio 2-697
Migrating Apps to 10 3-741
Win32 to 10 2-692
Great Visuals 263
XAML Commanding/Nav 297
XAML Perf 3-698
Great blog Colin! Fantastic info for your dev followers!