Preface

The personal computer (PC), which first hit the market over 30 years ago, has undergone tectonic changes that, in turn, launched the PC era. PCs were primarily used in the workplace where software was simple and optimized for use with the keyboard; touching a screen was unheard of until recently. Slowly computers began creeping into the home and many users didn’t know what to do with them; they were glorified typewriters.

When PCs started connecting to the Internet, possibilities reached a new level, which had a snowball effect. It allowed academia to share research; it spawned new means of communication from email and online chat to social networking, captivating the minds of people young and old. Soon consumers started using laptops and unplugging from the conventional desktop setting.

This shift had little impact on applications, but helped define a new wave of form factors in phones, tablets, and slates. Eventually, users started demanding more and we ushered in a new era, the modern consumer era. We are all modern consumers, not only consumers of goods, but consumers of information. We are constantly connected through the use of mobile devices as well as more traditional computers. Whatever type of device, be it static or mobile, content is synchronized and up-to-date. These new devices are used as gaming machines and personal entertainment centers, and they are replacing books and magazines for many avid readers.

Today, consumers expect developers to create apps where touch, mobility, and good battery life are a must. Tablets and slates leverage touch as a primary form of interaction while playing a critical role in the adoption of sensors and cameras in everyday computing. They are small and lightweight, making them extremely portable. Devices boot almost instantly so users can get to their content and put them right back in their bag without missing a step. Despite their youth, these devices are being embraced by work forces and consumers worldwide and they appear to be on a relentless progression.

With all this excitement, it’s hard to believe we’ve only begun to scratch the surface. We need a platform built from the ground up with these objectives in mind. This next version of Windows, code-named Windows 8, ships with a new application model for building user experiences tailored to the next generation of devices.

The Windows Runtime

The underpinning for that new user experience is the Windows Runtime. For years Windows desktop applications interacted with the Win32APIs in some fashion, whether they were opening file dialogs, rendering graphics, or communicating over the network. Instead of replacing this, Windows 8 continues its support for the Win32APIs allowing existing Windows 7 apps to run seamlessly. What they built instead is a brand new API from the ground up called the Windows Runtime (WinRT). WinRT consists of an application execution environment and a collection of new APIs, which enables a new line of immersive full screen apps called Windows 8 apps.

Windows desktop applications are still available and continue to be relevant for many situations. In fact, desktop applications can leverage the power of the Windows Runtime API—for example communicating with sensors.

Windows 8 apps are designed to communicate with WinRT via a language-independent projection layer, which enables apps to be written in statically-typed languages like C++, C#, and Visual Basic, while also feeling natural to dynamic languages like JavaScript. WinRT introduces a new trust model for users, called base trust. Unlike full trust, this model isolates each application while funneling high-level action through the runtime broker to ensure users are aware when apps attempt to access protected resources. Even though Windows 8 apps promote a model where the user is in charge, you will find their ability to connect with other apps is far superior than its predecessor. Windows 8 apps can communicate with other apps using generic contracts and send or receive content in various formats—like text and photos. Contracts can also be defined to access core operating system components, like Search, to highlight your app even though it may seem irrelevant. (We’ll discuss contracts and search later in Chapter 4.)

Note

Once a revolutionary technology, like mobile computing, has been unleashed it’s hard not to push its potential. You can already see signs that manufacturers and researchers are innovating well beyond what is on the streets today. Microsoft is committed to contributing to the future of technology in a big way and Windows 8 is just the start. For more insight and the impending possibilities into what’s next for Microsoft, a video of their vision for the future can be found online at http://www.youtube.com/playlist?list=PL2B8C6AB94E8259C6.

Disclaimer

Windows 8 is currently in Release Preview; as such, some of the content in this book may change.

Who This Book Is For

This book is written for existing .NET developers who are interested in the changes introduced with the release of Windows 8.

This book is intended to be a guide to developing complete Windows 8 apps. If you have an idea or you are just curious about the platform, this is the place to start. For a reference on all things related to Windows 8 development I recommend the Windows Dev Center at http://dev.windows.com and the Windows Dev Forum at http://forums.dev.windows.com.

The samples in this book are in C# and XAML. All of the samples in this book are available for download on this book’s website at http://bendewey.com/getting-started-with-metro-apps and at http://bendewey.com/getting-started-with-Windows8-apps.

How This Book Is Organized

This book focuses on helping you become familiar with the new Windows 8 landscape, WinRT, and writing your first Windows 8 apps, from creating a simple search app to writing a touch enabled app that responds to native sensors. This book will go through the steps taken to create a full application using the Bing Search API and publishing it to the Windows Store. It has been broken up into five chapters:

Chapter 1

This chapter focuses on a high-level overview of the Windows 8 features that power Windows 8 apps. From the new OS features, like the new Start Screen, to the in app features such as the Application Bar. Many of these features will be covered in depth in later chapters.

Chapter 2

Before building the full Bing Image Search application I will walk you through creating a simple version of the application that communicates with the Bing Search API and binds the results to a simple UI. If you choose to follow along you will need to obtain an account key for the Bing Search API service on the Azure Marketplace.

Chapter 3

Once you’ve seen how to create a simple application using the Bing Search API, I’ll show you what it takes to complete an application that leverages the full power of the Windows 8 platform. Chapter 3 will also focus on the goals, techniques, and designs used throughout the app.

Chapter 4

Developers can create impressive apps of all shapes and sizes. At some point you will need to access some external resource. Whether you’re communicating with web services or responding to events from one of the many native sensors, this chapter shows you how the Bing Image Search application takes advantage of these various features and how to implement them in a maintainable fashion.

Chapter 5

Windows 8 ships with a Windows Store that developers can leverage for marketing and distribution of their apps without having to focus on the nuances of building installers and accepting payments. As you would experience with other app stores, the Windows Store has a certification process. This chapter focuses on navigating that process and the details around app distribution in this new environment.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be touched, clicked, or typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.

Tip

This icon signifies a tip, suggestion, or general note.

Caution

This icon indicates a warning or caution.

What You Need to Use This Book

To run the samples from this book, you will need to have a version of Windows 8 Release Preview. I recommend installing to a virtual hard drive (VHD) using the steps laid out by Scott Hanselman at http://www.hanselman.com/blog/GuideToInstallingAndBootingWindows8DeveloperPreviewOffAVHDVirtualHardDisk.aspx.

In addition, you will need a version of Visual Studio 2012 available at http://www.microsoft.com/visualstudio/11.

Subscribing to the Bing Search API Service on Windows Azure Marketplace

This book uses the free Bing Search API service available from the Windows Azure Marketplace. This Service is a available for anyone to use as long as you register an account and subscribe. In order to use the examples in this book on your own you will need to create an account on the Windows Azure Marketplace and subscribe to the Bing service. This can be setup online by going to https://datamarket.azure.com/dataset/5ba839f1-12ce-4cce-bf57-a49d98d29a44, signing in with you LiveID by clicking the button in the top right, and then scrolling down and clicking the Sign Up button under the free 5,000 transaction subscription. After you’ve subscribed, you can click the EXPLORE THIS DATASET heading to play with the data feed.

Using Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Getting Started with Windows 8 Apps by Ben Dewey (O’Reilly). Copyright 2012 Ben Dewey, 978-1-449-32055-3.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

Safari® Books Online

Note

Safari Books Online (www.safaribooksonline.com) is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://oreil.ly/gs_with_windows_8_apps.

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

How to Contact the Author

Feel free to visit the books website at http://bendewey.com/getting-started-with-Windows8-apps. You can also find me on Twitter @bendewey or via email at .

Acknowledgements

I’d like to thank my employer, Tallan, for its support and for allowing me to attend conferences regularly. I’d also like to thank my editor, Rachel Roumeliotis, and my primary technical reviewer, Mark Freedmean, for putting up with me and the product throughout multiple changes as Windows 8 was a challenging, moving target. Finally, I’d like to thank my family for their undivided support and encouragement throughout the process.

Get Getting Started with Windows 8 Apps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.