Develop mobile, touch-based apps in less time
Windows 8 is the biggest transition for the Windows brand since 1995. It attempts to meet new challenges: the advent of touch as a primary interaction pattern, the growing threat of malware, and the need for extreme mobility in applications. For more information on Windows 8 development, see "How to Use Windows 8 Live Tiles in an Application" and "How to Work with Local Notifications in Windows 8-Style Apps."
Developers will be able to carry forward some of their existing knowledge into the new Windows 8 development world: You'll still be using Visual Studio, and if you have XAML expertise, you'll be able to carry that forward. C# and Visual Basic are both at your disposal for Windows 8 development. However, you'll also need a number of new skills. Some of these skills are purely technical, such as learning how to make your apps work with Windows 8 state management. You'll also need some softer skills: You must become fluent with touch for user interaction and become familiar with the user experience (UX) guidelines for Windows 8. You'll also have to learn how to work with the Windows Store for deploying your apps.
To help you make the shift, I'll run through the major new areas where you need to invest to prepare yourself to build apps for Windows 8. Most of them don't take huge amounts of time, but the list is longer than you might expect.
Learn Windows 8 Touch Conventions
Your first step is obvious. Get a touch-based Windows 8 machine, and begin using it routinely. Gestures such as swipes and tap/hold need to become second nature to you. Experience with a touch-based smartphone or tablet will shorten your learning period -- but it won't eliminate it.
Windows 8 has its own conventions for touch, and you'll need to be fluent with them. You'll need to learn about charms, app bars, and navigation bars. Figure 1 shows the basics, with a diagrammatic screen indicating those three elements. Each element is brought into view by swiping from a particular side of the screen: right for charms, bottom for app bar, and top for navigation bar.
Figure 1: The Major Elements that Swipe in from the Sides of a Windows 8 App
You also need to know your options. Charms are always present; they're part of the OS. But you get to choose whether to use an app bar, a navigation bar, or both. A lot of applications use just an app bar, which contains operations such as Save. But Internet Explorer, for example, uses only a navigation bar that navigates among browser tabs. Your app might need a similar navigation pattern.
Learn XAML Essentials
If you've been developing in Silverlight or Windows Presentation Foundation (WPF), you're in good shape to start using XAML in Windows 8. If you've done Windows Phone 7 development, you're even better prepared. However, if you lack such a background, then learning the raw essentials of XAML is probably your biggest hurdle for building XAML apps in Windows 8. You've got some major areas of expertise to acquire, including these:
- XAML syntax
- XAML layout and composition: how elements are arranged and combined
- data binding
- data templating
- styling and control templates
You can use existing resources, such as books and training videos, to become familiar with these XAML concepts. The general concepts, and quite a bit of the precise syntax, are the same in Silverlight/WPF as in Windows 8.
Understand XAML Differences for Windows 8
There are also many differences in the details of using XAML in Windows 8. Certain controls and elements found in WPF and Silverlight are missing, for example, and Windows 8 adds some new elements of its own. For example, the new GridView and FlipView controls integrate much of the touch navigation your users need to navigate a set of data items. You'll use ListBox less than in earlier XAML platforms, with GridView, FlipView, and ListView tending to fit better into a Windows 8 UX.
You'll have to contend with API differences as well. There are missing features, such as data binding for Style values. The syntax for setting an XML namespace in XAML has changed: Instead of using "clr-namespace" to prefix an assembly name, the prefix is now "using." These are just two examples of numerous minor differences.
Some API changes mean you'll need code modifications to bring over functionality from earlier XAML efforts. For example, the method signature has changed in the widely used IValueConverter interface.
Understand App Suspension and State Management
If you've done Windows Phone development, you'll be generally familiar with the pattern used to suspend and resume apps in Windows 8. The important factors to note are that your app might not remain in memory indefinitely; that's under control of the OS. That means there are some very explicit guidelines on functionality such as background processing.
As an app developer, your first responsibility in this area is to understand the events that occur during app navigation and what you typically need to do for those events. The most typical actions in the events are saving session state and restoring session state.
Session state in Windows 8 is conceptually like ViewState in ASP.NET pages, but session state resides in local memory, so it can be much richer. Session state consists of any information that the app doesn't want to lose when it's suspended. The two most important session-state events are
- OnLaunched, which fires when the application is first started but also fires whenever the app is brought back into view for actions such as loading a file. If necessary, this is where you need to reload session state. You also need to navigate to the appropriate view in this event.
- OnSuspending, which fires when execution is being suspended. This is where you typically save application state.
Two of the templates available in Visual Studio have typical sample code for handling these events and managing state. Let's take a look at the available templates.
The templates for XAML apps in Visual Studio. You get some serious help in constructing your app from the new application templates that come with Visual Studio 2012. For Windows 8-style apps, there are three built-in templates: the Blank App template, the Grid App template, and the Split App template.
The Blank App template isn't a good starting point for learning how to construct Windows 8 apps. Instead, you should start with the other templates, which include a lot of built-in functionality that a Windows 8 app needs. That doesn't mean the Blank App template is useless. Besides furnishing a way to quickly check features or APIs, it's also a good starting point for an app once you've mastered the requirements of Windows 8, especially if your app doesn't fit the interaction patterns supported by the other two templates. But you'll learn how a Windows 8 app is supposed to work faster by using the other templates.