Table of Contents

Introduction

Who This Book Is For

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

A Formatting Note

Acknowledgements

Errata & Book Support

We Want to Hear from You

Stay in Touch

Chapter 1: The Life Story of a Windows Store App: Platform Characteristics of Windows 8

Leaving Home: Onboarding to the Windows Store

Discovery, Acquisition, and Installation

Playing in Your Own Room: The App Container

Different Views of Life: View States and Resolution Scaling

Those Capabilities Again: Getting to Data and Devices

Taking a Break, Getting Some Rest: Process Lifecycle Management

Remembering Yourself: App State and Roaming

Coming Back Home: Updates and New Opportunities

And, Oh Yes, Then There’s Design

Chapter 2: Quickstart

A Really Quick Quickstart: The Blank App Template

Blank App Project Structure

QuickStart #1: Here My Am! and an Introduction to Blend for Visual Studio

Design Wireframes

Create the Markup

Styling in Blend

Adding the Code

Creating a Map with the Current Location

Oh Wait, the Manifest!

Capturing a Photo from the Camera

Sharing the Fun!

Extra Credit: Receiving Messages from the iframe

The Other Templates

Fixed Layout Template

Navigation Template

Grid Template

Split Template

What We’ve Just Learned

Chapter 3: App Anatomy and Page Navigation

Local and Web Contexts within the App Host

Referencing Content from App Data: ms-appdata

Here My Am! with ms-appdata

Sequential Async Operations: Chaining Promises

Error Handling Within Promises: then vs. done

Debug Output, Error Reports, and the Event Viewer

App Activation

Branding Your App 101: The Splash Screen and Other Visuals

Activation Event Sequence

Activation Code Paths

WinJS.Application Events

Extended Splash Screens

Activation Deferrals

App Lifecycle Transition Events and Session State

Suspend, Resume, and Terminate

Basic Session State in Here My Am!

Data from Services and WinJS.xhr

Handling Network Connectivity (in Brief)

Tips and Tricks for WinJS.xhr

Page Controls and Navigation

WinJS Tools for Pages and Page Navigation

The Navigation App Template, PageControl Structure, and PageControlNavigator

The Navigation Process and Navigation Styles

Optimizing Page Switching: Show-and-Hide

WinRT Events and removeEventListener

Completing the Promises Story

What We’ve Just Learned

Chapter 4: Controls, Control Styling, and Data Binding

The Control Model for HTML, CSS, and JavaScript

HTML Controls

WinJS stylesheets: ui-light.css, ui-dark.css, and win-* styles

Extensions to HTML Elements

WinJS Controls

WinJS Control Instantiation

Strict Processing and processAll Functions

Example: WinJS.UI.Rating Control

Example: WinJS.UI.Tooltip Control

Working with Controls in Blend

Control Styling

Styling Gallery: HTML Controls

Styling Gallery: WinJS Controls

Some Tips and Tricks

Custom Controls

Custom Control Examples

Custom Controls in Blend

Data Binding

Data Binding in WinJS

One-Time Binding

One-Way Binding

Implementing Two-Way Binding

Additional Binding Features

Binding Initializers

Binding Templates and Lists

What We’ve Just Learned

Chapter 5: Collections and Collection Controls

Collection Control Basics

Quickstart #1: The FlipView Control Sample

Quickstart #2a: The HTML ListView Essentials Sample

Quickstart #2b: The ListView Grouping Sample

ListView in the Grid App Project Template

The Semantic Zoom Control

FlipView Features and Styling

Data Sources

A FlipView Using the Pictures Library

Custom Data Sources

How Templates Really Work

Referring to Templates

Template Elements and Rendering

Template Functions (Part 1): The Basics

ListView Features and Styling

When Is ListView the Wrong Choice?

Options, Selections, and Item Methods

Styling

Backdrops

Layouts and Cell Spanning

Optimizing ListView Performance

Random Access

Incremental Loading

Template Functions (Part 2): Promises, Promises!

What We’ve Just Learned

Chapter 6: Layout

Principles of Windows Store App Layout

Quickstart: Pannable Sections and Snap Points

Laying Out the Hub

Laying Out the Sections

Snap Points

The Many Faces of Your Display

View States

Handling View States

Screen Size, Pixel Density, and Scaling

Graphics That Scale Well

Adaptive and Fixed Layouts for Display Size

Fixed Layouts and the ViewBox Control

Adaptive Layouts

Using the CSS Grid

Overflowing a Grid Cell

Centering Content Vertically

Scaling Font Size

Item Layout

CSS 2D and 3D Transforms

Flexbox

Nested and Inline Grids

Fonts and Text Overflow

Multicolumn Elements and Regions

What We’ve Just Learned

Chapter 7: Commanding UI

Where to Place Commands

The App Bar

App Bar Basics and Standard Commands

Command Events

App Bar Events and Methods

Showing, Hiding, Enabling, and Updating Commands

App Bar Styling

Custom Icons

Command Menus

Custom App Bars and Navigation Bars

Flyouts and Menus

WinJS.UI.Flyout Properties, Methods, and Events

Flyout Examples

Menus and Menu Commands

Context Menus

Message Dialogs

Improving Error Handling in Here My Am!

What We’ve Just Learned

Chapter 8: State, Settings, Files, and Documents

The Story of State

Settings and State

App Data Locations

AppData APIs (WinRT and WinJS)

Settings Containers

Versioning App State

Storage Folders and Storage Files

The FileIO, PathIO, and WinJS helper classes (plus FileReader)

Encryption and Compression

Using App Data APIs for State Management

Session State

Local and Temporary State

IndexedDB and Other Database Options

Roaming State

Settings Pane and UI

Design Guidelines for Settings

Populating Commands

Implementing Commands: Links and Settings Flyouts

Programmatically Invoking Settings Flyouts

User Data: Libraries, File Pickers, and File Queries

Using the File Picker

The File Picker UI

The File Picker API (and a Few Friends)

Media Libraries

Documents and Removable Storage

Rich Enumeration with File Queries

Here My Am! Update

What We’ve Just Learned

Chapter 9: Input and Sensors

Touch, Mouse, and Stylus Input

The Touch Language, Its Translations, and Mouse/Keyboard Equivalents

Edge Gestures

CSS Styles That Affect Input

What Input Capabilities Are Present?

Unified Pointer Events

Pointer Capture

Gesture Events

Multipoint Gestures

The Input Instantiable Gesture Sample

The Gesture Recognizer

Keyboard Input and the Soft Keyboard

Soft Keyboard Appearance and Configuration

Adjusting Layout for the Soft Keyboard

Standard Keystrokes

Inking

Geolocation

Sensors

What We’ve Just Learned

Chapter 10: Media

Creating Media Elements

Graphics Elements: Img, Svg, and Canvas (and a Little CSS)

Additional Characteristics of Graphics Elements

Some Tips and Tricks

Img Elements

Svg Elements

Canvas Elements

Video Playback and Deferred Loading

Disabling Screen Savers and the Lock Screen During Playback

Video Element Extension APIs

Applying a Video Effect

Browsing Media Servers

Audio Playback and Mixing

Audio Element Extension APIs

Playback Manager and Background Audio

The Media Control UI

Playing Sequential Audio

Playlists

Loading and Manipulating Media

Media File Metadata

Thumbnails

Common File Properties

Media-Specific Properties

Media Properties in the Samples

Image Manipulation and Encoding

Transcoding and Custom Image Formats

Manipulating Audio and Video

Transcoding

Custom Decoders/Encoders and Scheme Handlers

Media Capture

Flexible Capture with the MediaCapture Object

Selecting a Media Capture Device

Streaming Media and PlayTo

Streaming from a Server and Digital Rights Management (DRM)

Streaming from App to Network

PlayTo

What We Have Learned

Chapter 11: Purposeful Animations

Systemwide Enabling and Disabling of Animations

The WinJS Animations Library

Animations in Action

CSS Animations and Transitions

The Independent Animations Sample

Rolling Your Own: Tips and Tricks

What We’ve Just Learned

Chapter 12: Contracts

Share

Source Apps

Sharing Multiple Data Formats

Custom Data Formats: schema.org

Deferrals and Delayed Rendering

Target Apps

Long-Running Operations

Quicklinks

The Clipboard

Search

Search in the App Manifest and the Search Item Template

Basic Search and Search Activation

Providing Query Suggestions

Providing Result Suggestions

Type to Search

Launching Apps: File Type and URI Scheme Associations

File Activation

Protocol Activation

File Picker Providers

Manifest Declarations

Activation of a File Picker Provider

File Open Provider: Local File

File Open Provider: URI

File Save Provider: Save a File

File Save Provider: Failure Case

Cached File Updater

Updating a Local File: UI

Updating a Remote File: UI

Update Events

Contacts

Using the Contact Picker

Contact Picker Providers

What We’ve Just Learned

Chapter 13: Tiles, Notifications, the Lock Screen, and Background Tasks

Alive with Activity: A Visual Tour

The Four Sources of Updates and Notifications

Tiles, Secondary Tiles, and Badges

Secondary Tiles

Creating Secondary Tiles

App Activation From a Secondary Tile

Managing Secondary Tiles

Basic Tile Updates

Choosing a Tile Template

Creating the Payload, Method 1: Populating Template Content

Creating the Payload, Method 2: XML Strings

Creating the Payload, Method 3: The Notifications Extensions Library

Using Local and Web Images

Branding

Cycling, Scheduled, and Expiring Updates

Badge Updates

Periodic Updates

Web Services for Updates

Using the Localhost

Windows Azure

Toast Notifications

Creating Basic Toasts

Butter and Jam: Options for Your Toast

Tea Time: Scheduled Toasts

Toast Events and Activation

Push Notifications and the Windows Push Notification Service

Requesting and Caching a Channel URI (App)

Managing Channel URIs (Service)

Sending Updates and Notifications (Service)

Raw Notifications (Service)

Receiving Notifications (App)

Debugging Tips

Windows Azure Toolkit and Windows Azure Mobile Services

Background Tasks and Lock Screen Apps

Background Tasks in the Manifest

Building and Registering Background Task

Conditions

Tasks for Maintenance Triggers

Tasks for System Triggers (Non-Lock Screen)

Lock Screen–Dependent Tasks and Triggers

Debugging Background Tasks

What We’ve Just Learned (Whew!)

Chapter 14: Networking

Network Information and Connectivity

Network Types in the Manifest

Network Information (the Network Object Roster)

The ConnectionProfile Object

Connectivity Events

Cost Awareness

Running Offline

XmlHttpRequest

Background Transfer

Basic Downloads

Basic Uploads

Breaking Up Large Files

Multipart Uploads

Providing Headers and Credentials

Setting Cost Policy

Grouping Transfers

Suspend, Resume, and Restart with Background Transfers

Authentication, Credentials, and the User Profile

The Credential Picker UI

The Credential Locker

The Web Authentication Broker

Single Sign On

Single Sign On with Live Connect

The User Profile (and the Lock Screen Image)

Encryption, Decryption, Data Protection, and Certificates

Syndication

Reading RSS Feeds

Using AtomPub

Sockets

Datagram Sockets

Stream Sockets

Web Sockets: MessageWebSocket and StreamWebSocket

The ControlChannelTrigger Background Task

Loose Ends (or Some Samples To Go)

What We’ve Just Learned

Chapter 15: Devices and Printing

Using Devices

The XInput API and Game Controllers

Enumerating Devices in a Class

Windows Portable Devices and Bluetooth Capabilities

Near Field Communication and the Proximity API

Finding Your Peers (No Pressure!)

Advertising a Connection

Making a Connection

Tap to Connect and Tap to Activate

Sending One-Shot Payloads: Tap to Share

Printing Made Easy

The Printing User Experience

Print Document Sources

Providing Print Content and Configuring Options

What We’ve Just Learned

Chapter 16: WinRT Components: An Introduction

Choosing a Mixed Language Approach (and Web Workers)

Quickstarts: Creating and Debugging Components

Quickstart #1: Creating a Component in C#

Quickstart #2: Creating a Component in C++

Comparing the Results

Key Concepts for WinRT Components

Implementing Asynchronous Methods

JavaScript Workers

Async Basics in WinRT Components

Arrays, Vectors, and Other Alternatives

Projections into JavaScript

Scenarios for WinRT Components

Higher Performance

Access to Additional APIs

Obfuscating Code and Protecting Intellectual Property

Library Components

Concurrency

What We’ve Just Learned

Chapter 17: Apps for Everyone: Accessibility, World-Readiness, and the Windows Store

Your App, Your Business

Side Loading

Planning: Can the App Be a Windows Store App?

Planning for Monetization (or Not)

Free Apps

Ad-Supported Apps

Paid Apps and Trial Versions

In-App Purchases

Revenue Sharing and Custom Commerce for In-App Purchases

The Windows Store APIs

The CurrentAppSimulator Object

Trial Versions and App Purchase

Listing and Purchasing In-App Products

Receipts

Accessibility

Screen Readers and Aria Attributes

The ARIA Sample

Handling Contrast Variations

CSS Styling for High Contrast

High Contrast Resources

Scale + Contrast = Resource Qualifiers

High Contrast Tile and Toast Images

World Readiness and Localization

Globalization

User Language and Other Settings

Formatting Culture-Specific Data and Calendar Math

Sorting and Grouping

Fonts and Text Layout

Preparing for Localization

Part 1: Separating String Resources

Part 2: Structuring Resources for the Default Language

Creating Localized Resources: The Multilingual App Toolkit

Testing with the Pseudo Language

Localization Wrap-Up

Releasing Your App to the World

Promotional Screenshots, Store Graphics, and Text Copy

Testing and Pre-Certification Tools

Onboarding and Working through Rejection

App Updates

Getting Known: Marketing, Discoverability, and the Web

Connecting Your Website

Final Thoughts: Qualities of a Rock Star App

What We’ve Just Learned

About the Author

Survey Page