Added April 10, 2014 – The second edition has been finalized and published. See the new blog post here.
- Companion content for the Second Edition (second edition) [132 MB ZIP; code samples, plus 20 videos]
Kraig’s Introduction, which appears below, describes this ebook’s chapters and appendices. intended audiences, and accompanying samples and other companion content.
We’ll be publishing the final ebook (with 20 chapters & 4 appendices) in March/April in PDF, EPUB, and MOBI formats. In the meantime, enjoy the second preview!
As I mentioned in the first preview, this second edition is intended to stand alone for developers who are starting with Windows 8.1. It represents the state of Windows 8.1 rather than trying to document the delta from Windows 8. For this reason I don’t explain how to migrate apps from Windows 8 nor do I highlight many changes to APIs and behaviors (I do occasionally in specific cases). Check the Developer Center for such information.
That said, here’s what you’ll find in this second preview:
- Chapter 1, “The Life Story of a Windows Store App,” covers the core characteristics of the Windows platform. This is much the same as in Windows 8, with the biggest exception being the view model for apps where we now have a variable sizing model.
- Chapter 2, “Quickstart,” builds a first complete app, Here My Am!, that is gradually improved throughout the book. One significant change in this second preview is the use of thumbnails for loading and displaying images, which is a key performance consideration that you should always keep in mind. It’s very seldom that you need to load full image data.
- Chapter 3, “App Anatomy and Performance Fundamentals,” is much expanded from the first edition, especially including coverage of the WinJS Scheduler API for managing work on the UI thread, and a new section on debugging and profiling. I’ve also changed the title to reflect the importance of performance considerations from the earliest stages of your app building.
- Chapter 4, “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 x-ms-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.
- Chapter 5, “Controls and Control Styling,” is updated from the first edition’s Chapter 4 and includes the new WinJS.UI.ItemContainer control and discussed how to work with the WinJS dispose pattern.
- Chapter 6, “Data Binding, Templates, and Collections,” combines material from the first edition’s chapters on controls and collection controls. It’s helpful to look at templates by themselves, especially given optimizations that are introduced with WinJS 2.0. This chapter also looks at collection data types both in WinRT (types like the vector) and the WinJS.Binding.List, setting us up well for Chapter 7.
- Chapter 7, “Collection Controls,” focuses completely on the WinJS controls that provide UI for collections. These are the FlipView, ListView, Semantic Zoom, and Repeater controls. The ListView especially has many updates in WinJS 2.0, such as drag and drop support and better layouts (including custom layouts, see Appendix B).
- Chapter 8, “Layout and Views,” is much rewritten from the first edition’s chapter on layout, especially given the change from the distinct view states of Windows 8 to the variable sizing model of Windows 8.1. In addition, Windows 8.1 enables apps to have multiple views, which is a fun topic, and WinJS adds a new Hub control to support great home page experiences.
- Chapter 9, “Commanding UI,” is much the same as the first edition’s Chapter 7 and now includes the Nav Bar control that’s new in WinJS 2.0. The App Bar control also have improvements for easier customization.
- Chapter 10, “The Story of State, Part 1: App Data and Settings,” shares much of the first edition’s content from Chapter 8 but tells the story of app data much more clearly. I have to admit that I wasn’t wholly satisfied with the first edition’s treatment of the subject, and after giving several //build talks that helped me organize the material, it was clear that I needed to cleanly separate app data (Chapter 10) and user data (Chapter 11). That opened up space in Chapter 10 here to also cover file I/O basics, as well as the matter of streams, buffers, and blobs.
- Chapter 11, “The Story of State, Part 2: User Data, Files, and SkyDrive,” completes the discussion of working with files and folders, including the deep integration of SkyDrive that we have in Windows 8.1. This is another place we see the importance of using thumbnails when working with images, as it greatly helps to boost performance and reduce memory overhead, especially with collection controls.
- Chapter 12, “Input and Sensors,” was one of the easier chapters to update, as there aren’t many changes in these areas for Windows 8.1. The two main exceptions are the change from MSPointer* events to now-standard pointer* events, and the addition of geofencing APIs.
- Appendix A, “Demystifying Promises,” completes the discussion of promises that are introduced in Chapters 2 and 3. 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, “WinJS Extras,” is a collection of WinJS material that didn’t fit cleanly into other chapters, including WinJS.Namespace.define, WinJS.Class.define, obscure WinJS APIs, and custom layouts for the ListView control (where we even do circular and spiral layouts!).
- Appendix C, “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. Note that WinJS.xhr is covered here because Chapter 4 emphasizes the preferred Windows.Web.Http.HttpClient API.
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, http://www.kraigbrockschmidt.com/blog, where I’ve been working on various topics since we published the first edition. I’ll continue to be posting there, though a bit less frequently as I focus on completing this second edition.
Who This Book Is For
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 installed on your development machine, along with the Windows SDK for Windows 8.1 and the associated tools. All the tools, along with a number of other resources, are listed on the Windows 8.1 Downloads page. You’ll specifically need Microsoft Visual Studio Express 2013 for Windows. 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.)
I’ve seen some reviews of programming books that criticize authors for just pulling code samples from documentation rather than writing all their own code samples from scratch. Although I do provide a number of additional examples in this second preview’s companion content, it’s been one of my secondary goals 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. In most cases these samples are the same ones I would have written myself, and I’m very glad that wasn’t necessary! In a few cases I felt the samples lacked certain scenarios, so you’ll see some modified and extended samples in the companion content.
A big part of the companion content are the many revisions of the app I call “Here My Am!” (a variant of “Hello World.” We start building this in Chapter 2 and refine it throughout the course of the book. This includes localizing it into a number of different languages by the time we reach the end.
Something else I’ve done with this second preview is expand the use of video content. (All of the videos are also available in a folder with this preview’s companion content). As in the first edition, I’ve made a few longer videos to demonstrate use of the Visual Studio and Blend tools. In a number of other cases, it’s far easier to show dynamic effects in video than to explain them in text and screenshots. I’d also love to hear what you think about these.
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 App Builder Blog, which is a great resource to follow. 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.
We Want to Hear from You
At Microsoft Press, your satisfaction is our top priority, and your feedback our most valuable asset. Please tell us what you think of this ebook at https://aka.ms/tellpress.
The survey is short, and we read every one of your comments and ideas. Thanks in advance for your input!
Stay in Touch