Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Coverpage
Titlepage
Copyright
Dedication
Contents at a Glance
Contents
About the Author
About the Technical Reviewers
Acknowledgments
Part 1: Getting Started
Chapter 1: Putting Windows 8 in Context
Putting App Development in Context
Developing Windows Apps with JavaScript and HTML
Developing Apps with Visual Studio
Publishing Windows Apps
What Is in This Book?
Who Is This Book For?
What Do I Need to Know Before I Read This Book?
What If I Don’t Have That Experience?
What Don’t I Need to Know?
But Don’t I Have to Know C# for the Advanced Features?
What Tools and Technologies Do I Need?
What Is the Structure of This Book?
Part II: Core Development
Part III: UI Development
Part IV: Platform Integration
Part V: Selling Apps
Are There Lots of Examples in This Book?
What If I Want to Follow the Examples Myself?
Image Attribution
Chapter 2: Getting Started
Getting Set Up
Getting Visual Studio Ready
Optional Equipment
Getting Started
Creating the Visual Studio Project
Running the Project
Exploring the Project
Exploring the Project References
Exploring the Default Files
Understanding the Manifest
The Visual Studio Tools
The Visual Studio Editor
The JavaScript Console
The DOM Explorer
The Debugger
Summary
Chapter 3: Your First Windows 8 App
Understanding the App Structure
Revisiting the Example App Project
Creating the Navigation Infrastructure
Defining the Code
Dealing with the Global Namespace
Understanding Windows App Namespaces
Defining a Global Navigation Function
Displaying the Initial Page
Adding the Musical Note Font
Defining the App-Wide CSS
Adding the Selector Page
Defining the Selector Page CSS
Defining the Selector Page JavaScript Code
Summary
Chapter 4: Completing the App
Revisiting the Example App
Defining the Notes Data
Windows JavaScript Classes
Creating Namespaces
Adding the Flash Card Page
Adding the Page-Specific CSS
Defining the Code for the Flash Card Page
Using WinJS Data Binding
Defining the Data
Declaring the Bindings
Applying the Data to the Bindings
Configuring Buttons and Navigation
Configuring the Answer Buttons
Setting the State
Resetting the Other State Values
Showing the Flash Cards
Handling the Answer and Navigation Button Events
Relying on Data Bindings to Disseminate Data Updates
Updating the App Manifest
Setting the Tile Images and Color
Setting the App Name
Testing the Completed App
Windows Apps Build on Web Technologies
Windows Apps Are Not Web Apps
Data Binding Simplifies App Development
The WinJS API Is Written in JavaScript
Summary
Part 2: Core Development
Chapter 5: The Single-Page Model
Creating the Single-Page Project
Defining the Initial CSS
Defining the Initial JavaScript
Importing Content Declaratively
Understanding the Import Mechanism
Importing Content Programmatically
Using HtmlControl Programmatically
The Perils of Importing Interactive Content
Using the WinJS Pages Feature
Importing the Content
Registering the Callback
Ensuring the Content Order
Forcing a Content Order with Promises
Using the Navigation API
Handling the Navigation Events
Calling the Navigate Method
Using the Navigation History
Summary
Chapter 6: Creating an Adaptive Layout
Creating the Example Project
Understanding the Metro Views
Adapting to Views Using CSS
Adapting to the Filled View
Adapting to the Snapped View
Adapting to Views Using JavaScript
Detecting the Current View
Receiving View Change Events
Adapting to View Changes in Imported Content
Breaking Out of the Snapped View
Adapting to Device Orientation
Determining and Monitoring the Device Orientation
Using CSS to Adapt to Device Orientation
Expressing Your Device Orientation Preferences
Adapting to Pixel Density
Using Automatic Resource Loading
Adapting to Pixel Density Using JavaScript
Summary
Chapter 7: Commands & Navigation
Creating the Example Project
Defining and Loading the Content
Defining the JavaScript
Defining the CSS
Creating Application Commands
Declaring the AppBar Control
Adding Buttons to the AppBar
Responding to Commands
Adapting the AppBar to Specific Content
Using Flyouts
Creating Navigation Commands
Using a Standard NavBar
Using a Custom NavBar
Animating the Navigation Transition
Summary
Chapter 8: View Models & Data Binding
Revisiting the Example App
Decoupling App Components
Defining the View Model
Importing and Populating the View Model
Consuming the View Model
Separating Data from the Layout
Demonstrating the Problem
Applying the View Model
Using Data Binding
Making Objects Observable
Consuming Observable Object Events
Refactoring the Observable Properties
Using Declarative Bindings
Processing the Document
Declaring the Bindings
Creating Observable Arrays
Creating an Observable Array
Observing a List
Using Templates
Defining and Using the Template
Using Value Converters
Using an Open Value Converter
Summary
Chapter 9: Using Promises
Creating the Example Project
Dealing with the Basic Asynchronous Programming Flow
Using Asynchronous Callbacks
Creating Chains
Cancelling Promises
Passing a Result from a Promise
Coordinating Promises
Using the any method
Using the join method
Working with Timeouts
Applying the Same Callback Functions to Multiple Promises
Creating Custom Promises
Implementing the Promise
Deferring Execution
Implement Cancelation
Creating Synthetic Promises
Writing Your Own Synthetic Promise
Using the Wrapper Methods
Summary
Part 3: UI Development
Chapter 10: Creating the UI Controls Example Framework
Understanding the Final App
Creating the Basic Project Structure
Adding the Template Generation Code
Adding the Navigation Code
Adding the Other JavaScript Files
Adding the CSS
Creating the Test Content Page
Creating the Content page
Creating the Template System
Describing a Select Element
Adding the Element Generation Code
Generating a Select Element
Rendering the Template
Configuring & Populating the Select Element
Creating the Event Handler
Finishing Up
Using a Proxy Object
Adding the Definition Object
Creating the Proxy Object
Detecting and Using the Proxy Object
Responding to Proxy Object Property Changes
Generating the Other Element Types
Generating an Input Element
Generating a Span Element
Generating Button Elements
Generating ToggleSwitch Controls
Cleaning Up
Summary
Chapter 11: Using the ToggleSwitch, Rating and Tooltip Controls
Using the ToggleSwitch Control
When to use the ToggleSwitch Control
Demonstrating the ToggleSwitch Control
Applying and Configuring the ToggleSwitch Control
Styling the ToggleSwitch Control
Handling the ToggleSwitch Control Event
Using the Rating Control
When to use the Rating Control
Demonstrating the Rating Control
Applying and Configuring the Rating Control
Styling the Rating Control
Handling the Rating Control Events
Using the Tooltip Control
When to use the Tooltip Control
Demonstrating the Tooltip Control
Applying and Configuring the Tooltip Control
Managing the Tooltip Control Programmatically
Styling the Tooltip Control
Handling the Tooltip Events
Summary
Chapter 12: Using the Time/Date Pickers & Flyouts
Using the TimePicker Control
When to use the TimePicker Control
Demonstrating the TimePicker Control
Applying and Configuring the TimePicker Control
Managing the TimePicker Programmatically
Styling the TimePicker Control
Responding to the TimePicker Event
Using the DatePicker Control
When to use the DatePicker Control
Demonstrating the DatePicker Control
Applying and Configuring the DatePicker Control
Managing the DatePicker Programmatically
Styling the DatePicker Control
Responding to the DatePicker Event
Revisiting the Flyout Control
When to use the Flyout Control
Demonstrating the Flyout Control
Applying and Configuring the Flyout Control
Styling the Flyout Control
Handling the Flyout Events
Using the Flyout for User Interactions
Summary
Chapter 13: Using Menus & Dialogs
Using the Menu Control
When to use the Menu Control
Demonstrating the Menu Control
Applying and Configuring the Menu Control
Managing the Menu Programmatically
Styling the Menu Control
Handling the Menu Events
Using the MessageDialog Control
When to use the MessageDialog Control
Demonstrating the MessageDialog Control
Using the MessageDialog Control
Summary
Chapter 14: Using the FlipView Control
Using the FlipView Control
When to use the FlipView Control
Creating the FlipView Control Example
Creating and Using a Data Source
Applying the Data Source
Fixing the First Image Problem
Solutions to the First Image Problem
Configuring the FlipView Control
Setting the Orientation
Setting the Item Spacing
Managing the FlipView Programmatically
Moving through the FlipView Items
Manipulating the Data Source
Responding to the FlipView Events
Styling the FlipView Control
Using Custom Animations
Applying Custom Animations
Summary
Chapter 15: Using the ListView Control
When to use the ListView Control
Adding the ListView Example
Defining the ListView HTML
Defining the CSS
Defining the JavaScript
Working with the ListView Control
Selecting the Layout
Setting the Maximum Numbers of Grid Rows
Displaying Groups
Handling the ListView Events
Dealing with Invoked Items
Handling Item Selection
Styling the ListView Control
Managing the ListView Control Programmatically
Searching for Elements
Working with the Data Source
Dealing with Keys
Adding Items without Keys
Suppressing Update Events
Listening for Changes in the Data Source
Summary
Chapter 16: Using Semantic Zoom
When to use the SemanticZoom Control
Adding the SemanticZoom Example
Defining the HTML File
Defining the CSS
Completing the Example
Understanding the SemanticZoom Control
Creating the Zoomed In ListView Control
Creating the Zoomed Out ListView Control
Applying the SemanticZoom Control
Navigating between the SemanticZoom views
Configuring the SemanticZoom Control
Enabling and Disabling the Zoom Out Button
Setting the Zoom Factor
Handling the SemanticZoom Control Event
Styling the SemanticZoom Control
An Alternative to the SemanticZoom Control
Creating the List Context Example
Adding the Event Handler Code for the List Context Example
Summary
Chapter 17: Using Pointers & Gestures
Creating the Example Project
Defining the CSS
Defining the JavaScript
Determining the Input Capabilities of the Device
Determining the Keyboard Capabilities
Determining the Mouse Capabilities
Determining Touch Capabilities
Handling Pointer Events
Getting Pointer Information
Handling Gestures
Performing Basic Gestures
Handling Manipulations
Performing Manipulation Gestures
Handling the Manipulation Gesture Events
Using Content Zoom
Enabling the Content Zoom Feature
Applying Scaling Limits
Setting the Zoomed Content Style
Limiting the Range of Zoom Levels
Working with Content Zoom Programmatically
Summary
Chapter 18: Using Animations & Utilities
Working with Animations
Creating the Example Project
Working Directly with Elements
Using the Core WinJS Animation Methods
Using the WinJS Animations
Using the WinJS Utilities
Querying the DOM
Determining the Size and Position of Elements
Logging Messages
Summary
Part 4: Platform integration
Chapter 19: Understanding the App Lifecycle
Understanding the App Lifecycle
Activated
Suspended
Resumed
Terminated
Working with WinJS.Application
Building the Example App
Triggering Lifecycle Changes
Generating the Lifecycle Events in Windows 8
Suspending the App
Resuming the App
Terminating the App
Getting the Activation Type and Previous App State
Determining the Kind of Activation
Determining the Previous App State
Responding to Different Launch Types
Capturing the Resuming Event
Responding to Lifecycle Changes
Dealing with the Splash Screen
Dealing with App Termination
Dealing with App Suspension
Summary
Chapter 20: Working with Settings & App Data
Preparing the Example App
Preparing the Example App
Presenting Settings to the User
Defining the Flyout HTML
Responding to the settings Event
Making Settings Persistent
Storing Settings
Restoring Settings
Using Roaming Settings
Using App Data Files
Obtaining the Folder and File Objects
Writing to the File
Reading from the File
Loading Files from the App Package
Summary
Chapter 21: The Search Contract
Creating the Example App
Defining the View Model
Defining the JavaScript Code
Adding the App Images
Testing the Example App
Implementing the Search Contract
Handle the Activation Event
Working with the Search Pane
Activating Search
Providing Query Suggestions
Adding Separators to Suggestions
Providing Result Suggestions
Working with the Suggestion History
Making Suggestions Asynchronously
Summary
Chapter 22: Working with Files
Creating the Example App
Performing Basic File Operations
Copying Files
Deleting Files
Sorting and Filtering Files
Sorting Files
Filtering Files
Using the Advanced Query Syntax Properties
Using the Convenience Queries
Working with Virtual Folders
Grouping the Files
Processing the Grouped Files
Monitoring a Folder for New Files
Summary
Chapter 23: Integrating File Services
Creating the Example Application
Declaring the File Location Capability
Displaying an Image File
Using the File and Folder Pickers
Using the Example
Understanding the Code
Using the File Save Picker
Using the Folder Picker
Caching Location Access
Using the Access Cache
Using File Data Sources
Creating the Data Source
Generating the Template Data
Summary
Chapter 24: The File Activation & Picker Contracts
Creating the Example App
Defining the JavaScript
Testing the Example App
Adding the Images
Creating the Helper App
Implementing the File Activation Contract
Declaring the File Type Associations
Handling the File Activation Event
Making the App the Default Handler
Implementing the App-to-App Picking Contracts
Implementing the Save Picker Contract
Handling the Activated Event
Implementing the Open Picker Contract
Summary
Chapter 25: The Sharing Contract
Creating the Example App
Create a Share Source
Registering as a Share Source
Responding to the Event
Packaging the Shared Data
Testing the Share Source App
Understanding a Common Sharing Problem
Creating the Share Target
Updating the Manifest
Responding to the Activation Event
Processing the Share Operation
Testing the Share Target Implementation
Creating a Quick Link
Creating a Quick Link
Receiving a Quick Link
Summary
Chapter 26: The AutoPlay, Protocol Activation and Print Contracts
Revisiting the Example App
Implementing the AutoPlay Contract
Updating the Manifest
Responding to the Activation Event
Testing the Contract Implementation
Implementing the Protocol Activation Contract
Creating the Helper App
Adding Protocol Activation Support
Implementing the Printing Contract
Implementing Basic Printing
Manipulating the App Layout for Printing
Creating Print-Specific Content
Summary
Chapter 27: Working with App Tiles
Creating the Example for this Chapter
Defining the JavaScript
Setting the Tile Images
Testing the Example App
Creating a Live Tile
Creating a More Useful Live Tile
Using Templates with Images
Clearing a Tile
Using Badges
Advanced Tile Features
Using the Notification Queue
Updating a Notification
Scheduling Notifications
Determining if Notifications are Enabled
Summary
Chapter 28: Using Toast and the System Launcher
Using Toast Notifications
Creating the Example Application
Creating a Basic Toast Notification
Configuring the Toast Notification
Dealing with Toast Activation and Dismissal
Scheduling a Toast Notification
Determining Whether Toast Notifications Are Enabled
Using the App Launcher
Creating the Example App
Adding the Images
Defining the JavaScript Code
Testing the Example App
Using the App Launcher
Summary
Chapter 29: Working with Sensors
Creating the Example App
Working with Geolocation
Preparing the Geolocation Example
Getting a Location Snapshot
Tracking the Location
Using the Light Sensor
Taking a Snapshot of the Light Level
Tracking the Light Level
Testing the Light Sensor Example
Using the Inclinometer
Getting the Device Tilt
Using the Accelerometer
Getting the Device Acceleration
Using the Compass
Getting the Device Direction
Summary
Part 5: Selling apps
Chapter 30: Creating an App to Publish
Deciding On Your App
Deciding On Your Business Model
Getting Ready
Reserving the App Name
Creating the Visual Studio Project
Creating the Business Model Code
Creating the View Model State
Defining the Layout
Defining the CSS
Defining the JavaScript Code
Updating the Manifest
Testing the Example App
Summary
Chapter 31: Windows Store Integration
General Advice on App Licensing
Books and Apps Have a Lot in Common
Focusing on What Matters
Dealing with a Basic Store Scenario
Creating the Scenario File
Using the License Information
Enforcing the License Policy
Triggering the Capability Check
Dealing with Valid Trial Periods
Dealing with Expired Trial Periods
Adding Support for Buying the App
Summary
Chapter 32: Selling Upgrades
Defining the Products in the Scenario File
Defining the Remaining Products
Using the License Information
Processing the Product Licenses
Testing the License Information
Correcting the License Entitlements
Selling Upgrades
Dispatching State Events
Managing the Purchasing Process
Refreshing the App State
Buying the Upgrade
Testing the Scenario
Creating an In-App Store-Front
Enhancing the ViewModel.Store Namespace
Defining the Store Interactions
Defining the Markup and Styles
Writing the Code
Testing the In-App Store Feature
Adding the Real Product Data
Testing the In-App Store with Real Data
Summary
Chapter 33: Publishing to the Windows Store
Preparing the App Listing
Completing the Selling Details Section
Completing the Advanced Features Section
Completing the Age Rating Section
Completing the Cryptography Section
Associating the App with the Store
Providing a Store Logo
Removing the Store Simulation Code
Building the App Package
Completing the App Listing
Completing the Packages Section
Completing the Description Section
Completing the Notes for Testers Section
Submitting Your App
Summary
Index
← Prev
Back
Next →
← Prev
Back
Next →