Metro app meets Windows 10. A Microsoft win? Maybe after a little improvement
Hands on with the preview tools for the UAP
First Look Microsoft has released preview tools for the Windows 10 Universal App Platform (UAP), giving developers their first opportunity to try and build new-style Windows apps.
The tools, which you can find here, require the latest tech preview of Visual Studio 2015, as well as the preview of Windows 10 itself, so it is preview on preview on preview: not something for a production machine.
Documentation is currently both sketchy and confusing, thanks to Microsoft’s decision to re-purpose the name “Universal App”, already used for a Windows 8.1 project type that targets multiple platforms using shared code. You may have to trawl through these videos to get a detailed overview of the new platform.
It is worth noting that you do not have to use a Universal App to target Windows 10. It is still Windows, and Win32 projects both still work, with the advantage that they also run on Windows 7 and 8.
What is the difference between a new and old Universal App? Aside from incremental improvements, the key change is that a UAP project is a single project that runs on all supported platforms, which will include Windows 10 PCs, tablets, phones, Xbox One and Windows 10 IoT (Internet of Things).
Previously, a Universal App included multiple projects, one for shared code, and another for each supported platform, and you would build separate apps per platform.
The Windows Core platform
In order to achieve this level of compatibility, Microsoft has factored out a “Windows Core” which is common to all platforms. There are still plenty of device-specific features though, which you can target by referencing “Extension SDKs”, such as for Windows Desktop or Windows Mobile (yes, it is called Windows Mobile Extension SDK in the preview tools, suggesting that this old name may return).
If you use an Extension SDK, the referenced API will only work on that platform, but a stub API exists on the other platforms that does nothing. It is down to the developer to write code to detect whether it is present, using functions such as IsTypePresent or IsEventPresent.
Conditional compilation with #if still works, but it is discouraged since it breaks the UAP concept, taking you back to the old approach of separate builds for each device.
Another piece of the puzzle is what Microsoft calls the Adaptive UX, where you create a single user interface that adapts to the device. It is a similar approach to what on the web is called a Responsive UI, a web page that adapts itself to the display size and works on everything from mobile devices to desktop displays.
An Adaptive UX does not come for free, though; the developer has to consider different display or window sizes and write “Adaptive Triggers”, which change control properties according to the size of the display.
Creating an Adaptive UX is easier than it was, thanks to a new layout control called the RelativePanel, which lets you position child controls either relative to the panel, or relative to each other. You can say, for example, that you want a heading centred at the top, and an input box below the heading aligned to its left edge.
Like Metro in Windows 8 (also known as Store apps), a Universal App runs on top of the Windows Runtime (WinRT), a sandboxed environment that is also amenable to touch control. There are some useful enhancements to the WinRT platform in this release, including:
- Drag and drop support between apps and the Windows desktop, important for desktop integration
- App Services, a message-based API which lets one app call into a background task run by another app and obtain a result
- Shared storage: one app can pass a token to another app to enable it to open a shared file
- Support for the open source AllJoyn framework for IoT apps
- 3D transforms for graphical apps and effects
- WebView control based on the new “Project Spartan” engine for better standards support
- New Map control and services, so you easily overlay your own user interface elements on a map
- New Calendar control which is also used by the Universal App version of Outlook
- This is not an exhaustive list and there is more to come
Hands on with the developer tools
Following the release of the preview developer tools, I was quick to install and try coding some simple UAP apps.
Working with the new developer tools can be frustrating. One problem you may encounter is that dragging a control from the Visual Studio toolbox to the design surface breaks the app, by adding an reference to the Windows assembly (a library file) to the project.
The project no longer builds because of a ton of duplicate references. This bug is a clue to how a UAP project works. You are no longer targeting Windows directly, but rather the Universal App Platform, which is defined in an XML file buried in the SDK.
“Consider this is an early preview of the upcoming toolset,” said Microsoft product manager for the developer platform, Cliff Simpkins. “The controls and tooling are definitely not complete, and intended for evaluation, not for writing real code or apps.”
Working mainly with XAML (the layout language for WinRT) and C#, I put some controls on a page and compared the new UAP default look with the same XAML compiled as a Windows 8 Store app.
The differences are not huge, but the new one looks better, with larger text, a more elegant switch button, and an improved DatePicker that lets you click once instead of three times to select a date. You could adapt an old Store app to look the same, but the default appearance is important.
Store app and Universal App side by side
Tastes vary, but it would be hard to describe Microsoft’s UAP as beautiful by default. On Apple’s iOS, for example, you get more elegant controls out of the box (though you can still make ugly apps of course).
Next, I ran the same app on the Windows Phone 10 emulator included in the toolkit. The emulator took an age to start on my Core i5, but the app ran well, though if you squint at the image you will see that the “Click me” button on the phone slightly overlaps the top heading.
This kind of issue is one of the hazards of cross-device UIs, though note that in this case I was using the old StackPanel, not the new RelativePanel. Perhaps that would fix it.
A Universal App on Windows Phone 10
I did try out the RelativePanel, which performs as advertised, as well as the SplitView which is a new way to manage navigation. Using the SplitView, you get a vertical navigation bar on the left, and a frame within which you can display app pages on the right. The SplitView is rather good and likely to be popular with developers in search of a quick and easy way to build a functional business app.
I also tried compiling the same XAML with C++ rather than C#. C# is a .NET language, and all .NET apps are compiled to native code when you do a release build, according to Microsoft. This is a new technology which creates a standalone app, linking all the .NET dependencies into the app itself.
This means that the load time and performance of a C# app should be close to that of C++. However, in practice the XAML/C++ app loads noticeably faster than the C# app. I did not try to test performance of the app once loaded, but this is already a good reason to use C++ if such differences remain.
Note that DirectX 12 is also supported with C++, either with or without XAML, for game development.
UAP pros and cons
The Windows 10 Universal App Platform already looks more mature than the Windows 8 “Metro” platform. Microsoft has built a cut-down version of Office on the platform, and this internal effort will have put pressure on the Windows team to improve the tools and add missing pieces. Will it fare better amongst developers?
It is a complex question of which the quality of the platform is only part of the answer. Developers want to make money and meet the demands of users. Demand for Windows 8 Store apps is low, because most Windows users live in the desktop most of the time.
Developers are generally better off creating Win32 apps that also run on Windows 7, rather than dedicating resources to a minority platform.
With the UAP, App developers will still miss out on the Windows 7 market, but do get Windows Phone for free, and although Windows Phone has a small market share (especially in the USA), it is big enough to generate some demand.
It is also likely that Windows 10 users will have more interest in UAP apps than Windows 8 users have for Store apps. This is because of desktop integration and apps that run in a window rather than full screen.
The success of Windows 10 could drive UAP adoption, and vice versa; or the failure of Windows 10 could kill both. This likely explains why Microsoft is throwing everything at Windows 10, including eye-catching features such as HoloLens augmented reality, free upgrades, and free OEM versions on smaller devices.
It will still not be easy, since the public perception is largely one where smartphone or tablet means iOS or Android.
These last two currently create Store apps rather than UAP apps, but that is likely to change.
Blend for Visual Studio
The attraction of XAML, the presentation language which is the preferred approach for most apps of any complexity, is harder to assess. Microsoft does have a visual designer for XAML, in the Blend tool which comes as part of Visual Studio, but learning to use XAML, Blend and the complexities of styling, app navigation and lifecycle in a WinRT app (whether or not Universal) is a challenge.
There is also a simple XAML visual designer in Visual Studio itself, though many developers end up editing XAML code manually for the most predictable results.
Anyone picking up the preview tools who is not already steeped in the mysteries both of XAML and of Microsoft’s development ecosystem will probably give up quickly. Go here, for example, so see what is new in Windows 10 Developer Preview.
Then click the prominent link for “Universal app platform guide” and you end up (at the time of writing) on a page devoted to the old Universal apps. This kind of misdirection is common enough that you just shrug, but the company needs to do better.
The verdict is mixed then: a big advance from the old Store apps, but plenty more for Microsoft to do. ®