Windows 8 has two personalities: the familiar desktop side and the new tablet-friendly side which you see every time you show the Start screen. While the desktop offers improved performance and some user interface tweaks, it is not profoundly different from Windows 7.
The new personality, by contrast, is a radical innovation. Apps run either full screen or in a split view which allows at most two apps to be shown. The user interface is designed for touch control as well as mouse and keyboard. Most users acquire apps exclusively from the Windows Store, although ‘sideloading’ of custom apps is possible in an enterprise context. Microsoft, and Visual Studio, calls these apps Windows Store apps.
Under the covers, a Windows Store App runs in a sandboxed environment called the Windows Runtime or WinRT. This is not to be confused with Windows RT, the name Microsoft has given to Windows when running on ARM devices rather than Intel. The Windows RT factor is important though, since on Windows RT you can only install WinRT apps. There is a desktop, but it is locked down so that no new apps can be installed.
Developers therefore have several reasons to build Windows Store Apps:
This last requires some explanation. Modern App is jargon Microsoft has been using recently to describe apps offering a rich user experience and designed for a world of continuous services and connected devices. The term ‘devices’ suggests tablets and smartphones, including those that do not necessarily belong to the business but might be used at home as well, a trend that is being called BYOD (Bring Your Own Device).
Windows Store apps fit well with this idea. They are designed to depend for data on secure Internet services rather than local databases, to run in a sandboxed environment where they are isolated from other apps as well as from the operating system, and to support rich interactivity through capabilities such as transition animations and DirectX graphics.
WinRT is the platform and API for Windows Store apps. A Windows Store app is a Windows executable, but one that is allowed to call a safe subset of the Win32 API supplemented by the new WinRT API.
A key feature of WinRT is that there is no inter-process communication beyond what is allowed though Contracts and Extensions, which are carefully controlled means of sharing data, and no use of shared libraries beyond what Microsoft supplies. An app has access to local storage but only in its own isolated area. If your app needed to open or save a document in the users My Documents folder, for example, it would do so through the file picker contract under user control.
“I found the tools provided for developing Windows Runtime applications to be fairly complete, but there are shortcomings and lots of room for improvement. If your application is simple, you can be pretty confident with using the tools to develop and deploy a Windows Runtime application to the Store without much trouble. The IDE provides all sorts of wizards for filling out information about your application, and running a pre-certification check before you submit it to the store. There’s even a simulator for you to simulate multi-touch scenarios on your application.”
– Winston Pang, developer on Pixel Tucker’s Twitter client for Windows 8, MetroTwit
WinRT APIs can be accessed from three different platforms. The first is C/C++. Here you would normally use the Visual C++ component extensions (C++/CX). This is a subset of C++/CLI which is used to target the .NET Common Language Runtime (CLR).
The final option is .NET. Here, Microsoft’s language projection makes WinRT look like a .NET API, and in fact the metadata format which publishes the API is the same. This makes coding a WinRT app in .NET very natural. It is executed by the same CLR that is used for desktop applications, but with the caveat that only a subset of the full .NET Framework is available, either for security reasons or because there is a WinRT API you should use instead. For example, there is no ADO.NET for data access. You can use a local database such as the open source SQLite (which is supported via a specific WinRT extension) but this has its own data access library. There is no client for SQL Server.
The user interface for a WinRT app is composed in one of three ways:
WinRT apps have a different look and feel from old-style Windows applications. This extends from the look of the controls to the way the user navigates the UI. The philosophical approach is ‘Content before Chrome’, prioritising the content above potentially distracting tools and controls. The free Windows 8 design guide, currently called the User Experience Guidelines, is essential reading for WinRT developers and designers.
It also pays to use the supplied templates in Visual Studio as these represent a best-practice starting point. Consistent apps are more intuitive for users.
Visual Studio includes a simple XAML designer for Windows Store Apps, but there is no visual designer for HTML, although Visual Studio comes with Expression Blend, a design tool for both HTML and XAML. You can right-click an HTML or XAML file in the Solution Explorer and choose Open in Blend, make your changes, then return to Visual Studio.
Instead of a menu bar, which could distract from content, Windows Store Apps support App Bars. These can appear at top or bottom when activated by a right-click with the mouse or swipe in with fingers. Apps can also provide a UI for settings via the Charms bar, which appears when the user moves the mouse to the top or bottom right corner, or swipes in from the right hand side.
Contracts and Extensions provide a mechanism for Windows Store apps to communicate with each other and with Windows 8 itself. Search lets your app participate in user searches. Settings lets your app offer a settings UI via the Charms. Share lets your app exchange data with other apps. File Picker lets users pick a file to open or manipulate in your app, while Cached File Updater triggers events needed to update files downloaded from a cloud service. The Print contract lets you register your app for printing support.
Extensions cover operating system interaction. For example, you can register an app to be listed as an AutoPlay choice for certain AutoPlay events, like connecting a camera. The Background tasks extension lets you run code even when app is suspended.
Windows Store apps, like apps for Windows Phone, are designed to be suspended or even terminated automatically. Apps are normally suspended when the user switches to another app. You can handle application events like OnSuspending so that you can save the state and the user can resume later. Events also fire when apps are re-oriented from portrait to landscape, or placed into a split view. Developers need to ensure that their app is well behaved.
Microsoft has simplified the process of getting an app into the Store through a Store option on the Project menu in Visual Studio. The first step is to open a developer account. Next, you reserve a name for your app, specify information such as age rating, and complete a manifest specifying the app’s capabilities, which has implications for the permissions it will need, such as access to location data.
Apps are subject to both automated and human testing before approval for the store. You can perform your own tests using the App Certification Kit which runs through some basic checks for correct behaviour. You can also test and debug on your own Windows 8 machine, or using the simulator installed with Visual Studio – which is really a remote session into your own PC, so be careful!
That done, you can upload your app, packaged by Visual Studio, for checking and approval by Microsoft. The store supports both free and paid apps, trial apps, and in-app purchase.
Developers testing apps and businesses deploying custom apps do not need to go via the Store. The alternative is called ‘sideloading’. On machines that meet sideloading requirements, you can install apps with a PowerShell script. Sideloading is allowed on domain-joined Windows 8 Enterprise or Server 2012 machines. It can also be done on other editions of Windows 8, but requires a sideloading product key.
Microsoft’s Satya Nadella, speaking at the launch of Visual Studio 2012 in Seattle, called Windows 8 a “400 million opportunity”, based on predictions of first year sales. Getting in early on a new platform can get you a lot of much-needed attention.
Designing and building Windows Store apps
Dev Center for Windows Store apps
Windows Store app samples
User Experience guidelines for Windows Store apps