First preview: Programming Windows Store Apps with HTML, CSS, and JavaScript, Second Edition

First preview: Programming Windows Store Apps with HTML, CSS, and JavaScript, Second Edition

  • Comments 3

Brockschmidt_first preview.inddAdded October 29, 2013: The second preview is now available (with 12 final chapters and 3 final appendices) here!



Greetings. To add to the great information being shared at //build/ this year, we’re happy to provide a First Preview of the upcoming second edition of Kraig Brockschmidt’s Programming Windows Store Apps with HTML, CSS, and JavaScript!

As you might remember, over the course of 2012, we published three versions of the first edition: First Preview, Second Preview, and the final release. All were free. And we’ll be doing the same thing with the second edition; all three releases will be free.

Lots of information about this preview appears in the Introduction excerpt below, including a link to the companion content for this release.

And the 255-page PDF itself can be downloaded here: (5.57 MB)

FYI, we’ll be providing EPUB and MOBI for the ebook’s final release, not for the two preliminary releases.

Also, please remember that this material is in DRAFT form. This content will not be final until the ebook’s final release.




It seems like it was only a few months ago that I was writing the introduction for the first edition of this book, Programming Windows 8 Apps in HTML, CSS, and JavaScript. Of course, it was only 8 months ago! It’s been a remarkably short time between the release of Windows 8 and the Windows 8.1 Preview that we’ve made available as of June 26th 2013 for the //build conference. And yet much has been improved in the Windows platform during that time.

First of all, however, let me thank the hundreds of thousands of readers who downloaded the first edition of this ebook, both directly from Microsoft Press and from the Amazon Kindle store where the book has maintained a high ranking among programming titles as well as within the broader computer & technology category. I’m delighted that this work has been serving you well, and I was certainly inspired to start in on this second edition as soon as I began reading the specifications for Windows 8.1 Preview. My notes on what to add, what to change, and what to expand are quite lengthy!

In this First Preview of the second edition, which constitutes only those chapters that I and my editors have worked through so far, I will not cover the whole Windows 8.1 Preview story, of course. For that I can still recommend the first edition of this book as a basis. Then check out the session videos from //build 2013 that you can find through The Windows Developer Center,, also has updated documentation that covers the Windows 8.1 Preview, so you can find much more there. I can specifically recommend Windows 8.1 Preview: New APIs and features for developers.

This second edition is intended to stand alone for developers who are starting with Windows 8.1 Preview. It represents the state of Windows 8.1 Preview rather than trying to document the delta from Windows 8. For this reason I’m not going into much detail about migrating apps from Windows 8 nor trying to highlight all the changes to both APIs and behaviors. Check the Developer Center for such information.

Here’s a quick summary of what’s in this First Preview:

  • Chapter 1, “The Life Story of a Windows Store App,” is much the same as in the first edition, with some small additions. For the most part, the core characteristics of the Windows platform is the same as with Windows 8, with the biggest exception being the view model for apps where we now have a variable sizing model.
  • Chapter 2, “Quickstart,” is updated for Windows 8.1 Preview, and I’ve added some sections that cover extra improvements to the Here My Am! app that we’ll be building over the course of the book.
  • Chapter 3, “App Anatomy, Page Navigation, and Promises,” is expanded from the first edition. Besides updating the text for small bits like new tile sizes in Windows 8.1 Preview, I’ve added a section on extended splash screens, tightened up the discussion of promises, written out some details of the new task scheduler for the UI thread, and included a new section on debugging and profiling.
  • Chapter 4, “Using Web Content and Services,” is a mixture of new content and networking topics from the first edition’s Chapter 14. I moved these topics earlier in the book because using web content is increasingly important for apps, if not essential. This chapter covers network connectivity, hosting content (especially with the new webview control), making HTTP requests (especially through the new Windows.Web.Http.HttpClient API), background transfers (which have been improved), authentication, and a little on Live Services.
  • Appendix A, “Demystifying Promises,” completes the discussion of promises that starts in Chapter 3. That is, Chapter 3 covers the essentials about using promises, which are often returned from asynchronous Windows Runtime APIs. After writing the first edition, I wanted to spend more time with promises for my own sake, but it’s just my nature to leave a paper trail of my learnings! So, in this appendix we start from scratch about what promises are, see how promises are expressed in WinJS, explore how to create and source promises, and then pick apart some specific promise-heavy code.
  • Appendix B, “Additional Networking Topics,” contains material that is related to Chapter 4 but didn’t fit into that flow or that is more peripheral in nature.

As you can see, in this second edition I’ll be using appendices to go deeper into certain topics that would be too much of a distraction from the main flow of the chapters. Let me know what you think. Some of this material I’ve already posted on my blog,, where I’ve been working on various topics since we published the first edition. I’ll continue to be posting there, though perhaps not quite on a daily basis as work on this second edition takes priority!

Be mindful that the chapter organization of this second edition is still in flux, so references to later chapters are subject to change. As you can expect from the length of the change list I mentioned earlier, I’m going to be adding many pages to this second edition that all need to be appropriately organized!

Who This Book Is For

This book is about writing Windows Store apps using HTML5, CSS3, and JavaScript. Our primary focus will be on applying these web technologies within the Windows 8 and Windows 8.1 Preview platform, where there are unique considerations, and not on exploring the details of those web technologies themselves. For the most part, then, I'm assuming that you're already at least somewhat conversant with these standards. We will cover some of the more salient areas like the CSS grid, which is central to app layout, but otherwise I trust that you're capable of finding appropriate references for most everything else.

That said, much of this book is not specific to HTML, CSS, or JavaScript at all, because it’s focused on the Windows platform and the Windows Runtime (WinRT) APIs. As such, at least half of this book will be useful to developers working in other languages (like C# or C++) who want to understand the system better. Much of Chapter 4 and Appendix B in this First Preview, for example, is specific to WinRT. The subjects of app anatomy and promises in Chapter 3 and Appendix A, on the other hand, are very specific to the JavaScript option. In any case, this is a free ebook, so there’s no risk, regardless of your choice of language and presentation technology!

In this book I'm assuming that your interest in Windows has at least two basic motivations. One, you probably want to come up to speed as quickly as you can, perhaps to carve out a foothold in the Windows Store sooner rather than later. Toward that end, I've front-loaded the early chapters with the most important aspects of app development that also give you experience with the tools, the API, and some core platform features. On the other hand, you probably also want to make the best app you can, one that performs really well and that takes advantage of the full extent of the platform. Toward this end, I've also endeavored to make this book comprehensive, helping you at least be aware of what's possible and where optimizations can be made.

Many insights have come to me from working directly with real-world developers on their real-world apps. As part of the Windows Ecosystem team, myself and my teammates have been on the front lines bringing those first apps to the Windows Store. This has involved writing bits of code for those apps and investigating bugs, along with conducting design, code, and performance reviews with members of the Windows engineering team. As such, one of my goals with this book is to make that deep understanding available to many more developers, including you!

What You'll Need (Can You Say “Samples”?)

To work through this book, you should have Windows 8.1 Preview installed on your development machine, along with the Windows SDK for Windows 8.1 Preview and the associated tools. All the tools, along with a number of other resources, are listed on the Windows 8.1 Preview page. You’ll specifically need Microsoft Visual Studio Express 2013 for Windows 8.1 Preview. We’ll also acquire other tools along the way as we need them in this ebook. (Note that for all the screen shots in this book, I switched Visual Studio from its default “dark” color theme to the “light” theme, as the latter works better against a white page.)

Also be sure to download the Samples pack listed on this page, or visit Windows app samples and specifically download the SDK’s JavaScript samples. We'll be drawing from many—if not most—of these samples in the chapters ahead, pulling in bits of their source code to illustrate how many different tasks are accomplished.

One of my secondary goals in this book, in fact, is to help you understand where and when to use the tremendous resources in what is clearly the best set of samples I’ve ever seen for any release of Windows. You’ll often be able to find a piece of code in one of the samples that does exactly what you need in your app or that is easily modified to suit your purpose. For this reason I’ve made it a point to personally look through every one of the JavaScript samples, understand what they demonstrate, and then refer to them in their proper context. This, I hope, will save you the trouble of having to do that level of research yourself and thus make you more productive in your development efforts.

In some cases I’ve taken one of the SDK samples and made certain modifications, typically to demonstrate an additional feature but sometimes to fix certain bugs or demonstrate a better understanding that came about after the sample had to be finalized. I’ve included these modifications in the companion content for this book, which you can download at (40.1 MB)

That companion content also contains a few additional examples of my own, which I always refer to as “examples” to make it clear that they aren’t official SDK content. (I’ve also rebranded the modified samples to make it clear that they’re part of this book.) I’ve written these to fill gaps that the SDK samples don’t address, or to provide a simpler demonstration of a feature that a related sample shows in a more complex manner. You’ll also find many revisions of an app I call “Here My Am!” that we’ll start building in Chapter 2 and again refine throughout the course of this book. This includes localizing it into a number of different languages by the time we reach the end. (By the way, you might find that with Windows 8.1 Preview that the app runs better outside the debugger; in the debugger I’ve seen issues getting geolocation readings, which limits the app’s functionality quite a bit.)

The companion content includes a few videos that explain how to use tools like Visual Studio and Blend much better than text. Note that with this First Preview, though, that I have not updated these videos to the Windows 8.1 Preview tools. They’re still be useful, but keep an eye out for changes (such as the Device tab in Blend).

Beyond all this, you’ll find that the Windows samples gallery as well as the Visual Studio sample gallery also lets you search and browse additional projects that have been contributed by other developers—perhaps also you! (On the Visual Studio site, by the way, be sure to filter on Windows Store apps because the gallery covers all Microsoft platforms.) And, of course, there will be many more developers who share projects on their own.

In this book I occasionally refer to posts on the Windows 8 App Developer blog, which has recently become the Windows App Builder Blog. This is a great resource to follow, and you might also refer to the Windows Store for Developers blog, which has also merged into the App Builder site. And if you’re interested in the Windows 8 backstory—that is, how Microsoft approached this whole process of reimagining the operating system—check out the Building Windows 8 blog.

Some Formatting Notes

Throughout this book, identifiers that appear in code—such as variable names, property names, and API functions and namespaces—are formatted with a color and a fixed-point font. Here’s an example: Windows.Storage.ApplicationData.current. At times, a fully qualified name like this—those that include the entire namespace—can become quite long and don’t readily break across lines. In this First Preview we’ve elected not to hyphenate these, so with something like Windows.Security.Cryptography.CryptographicBuffer.convertStringToBinary you’ll see a gap on the previous line. We’ll take care of these for the final version of this second edition.

For simplicity’s sake (and because such hyphens produced some headaches in the first edition of this book), I’ve often omitted the namespace because I trust you’ll see it from the context. Plus, it’s easy enough to search on the last piece of the identifier on and find its reference page—or just click on the links I’ve included.

Occasionally, you’ll also see an event name in a different color, as in datarequested. These specifically point out events that originate from Windows Runtime objects, for which there are a few special considerations for adding and removing event listeners in JavaScript to prevent memory leaks, as discussed in Chapter 3. I make a few reminders about this point throughout the chapters, but the purpose of this special color is to give you a quick reminder that doesn’t break the flow of the discussion otherwise.

  • سلام ترجمه صفحه به زبان فارسی با درصد خطای بالایی نمایش دده میشود

  • totally agree with you

  • I transalted with google translate what "MehradSys" said:

    "Hi translated pages in Farsi, with a high percentage error is displayed Dede" (I Don't know what is it "dede")

Page 1 of 1 (3 items)
Leave a Comment
  • Please add 5 and 3 and type the answer here:
  • Post