Tải bản đầy đủ

820 windows phone 7 development internals

www.it-ebooks.info


www.it-ebooks.info


Windows Phone 7
Development Internals
®

Andrew Whitechapel

www.it-ebooks.info


Published with the authorization of Microsoft Corporation by:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, California 95472
Copyright © 2012 by Andrew Whitechapel.
All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any

means without the written permission of the publisher.
ISBN: 978-0-7356-6325-1
1 2 3 4 5 6 7 8 9 LSI 6 5 4 3 2 1
Printed and bound in the United States of America.
Microsoft Press books are available through booksellers and distributors worldwide. If you need support related
to this book, email Microsoft Press Book Support at mspinput@microsoft.com. Please tell us what you think of
this book at http://www.microsoft.com/learning/booksurvey.
Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty/
Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of
their respective owners.
The example companies, organizations, products, domain names, email addresses, logos, people, places, and
events depicted herein are fictitious. No association with any real company, organization, product, domain name,
email address, logo, person, place, or event is intended or should be inferred.
This book expresses the author’s views and opinions. The information contained in this book is provided without
any express, statutory, or implied warranties. Neither the authors, O’Reilly Media, Inc., Microsoft Corporation,
nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly
or indirectly by this book.
Acquisitions Editor: Russell Jones
Developmental Editor: Russell Jones
Production Editor: Melanie Yarbrough
Editorial Production: Octal Publishing, Inc.
Technical Reviewer: Peter Torr
Copyeditor: Bob Russell
Indexer: WordCo Indexing Services
Cover Design: Twist Creative • Seattle
Cover Composition: Karen Montgomery
Illustrator: Robert Romano

www.it-ebooks.info


Contents at a Glance
Forewordxvii
Introductionxix
Part I

Building Blocks

Chapter 1


Vision and Architecture

Chapter 2

UI Core

Chapter 3

Controls61

Chapter 4

Data Binding and Layer Decoupling

Chapter 5

Touch UI

Part II

Application Model

Chapter 6

Application Model

175

Chapter 7

Navigation State and Storage

199

Chapter 8

Diagnostics and Debugging

243

Part III

Extended Services

Chapter 9

Phone Services

291

Chapter 10

Media Services

319

Chapter 11

Web and Cloud

349

Chapter 12

Push Notifications

409

Chapter 13

Security445

Chapter 14

Go to Market

Part IV

Version 7.5 Enhancements

Chapter 15

Multi-Tasking and Fast App Switching

553

Chapter 16

Enhanced Phone Services

589

Chapter 17

Enhanced Connectivity Features

627

Chapter 18

Data Support

667

Chapter 19

Framework Enhancements

711

Chapter 20

Tooling Enhancements

745

3
29
91
135

499

Index773
www.it-ebooks.info


www.it-ebooks.info


Contents
Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

Part I

Building Blocks

Chapter 1 Vision and Architecture

3

Windows Phone Vision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Metro. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Developer Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Windows Phone Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Comparison of Silverlight and XNA . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Developer Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Development Cycle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
The Anatomy of a Basic Windows Phone Application . . . . . . . . . . . . . . . . 13
XAP Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Standard Project Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Themes and Accent Colors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Standard Application Images. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Version 7 vs. Version 7.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27

Chapter 2 UI Core

29

Phone UI Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Standard UI Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Visual Tree. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Screen Layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
UserControl vs. Custom Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Routed Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Content vs. Resource. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Resource Dictionaries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49


v

www.it-ebooks.info


Dependency and Attached Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Dependency Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Attached Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Chapter 3 Controls61
Standard Controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Platform, SDK, Toolkit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
SDK Controls: Pivot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
SDK Controls: Panorama. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Toolkit Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Transient Panels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89

Chapter 4 Data Binding and Layer Decoupling

91

Life without Data Binding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Simple Data Binding and INotifyPropertyChanged. . . . . . . . . . . . . . . . . . . .94
Data Binding Collections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Data Templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Dynamic Data-Bound Collections. . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Template Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Type/Value Converters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Element Binding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Data Validation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Separating Concerns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Design-Time Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
The Model-View ViewModel Pattern. . . . . . . . . . . . . . . . . . . . . . . . . 117
The Visual Studio Databound Application Project. . . . . . . . . . . . . . . . . . . 124
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133

viContents

www.it-ebooks.info


Chapter 5 Touch UI

135

Logical Touch Gestures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Manipulation Events: Single Touch (Tap) . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Manipulation Events: Single Touch (Flick). . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Manipulation Events: Multi-Touch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Mouse Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
FrameReported Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Combining Manipulation and Mouse Events. . . . . . . . . . . . . . . . . . . . . . . . 148
Click vs. Mouse/Manipulation Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
The Silverlight Toolkit GestureService. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Pinch and Drag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Flick and Tap. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Problems with the GestureService. . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Keyboard Input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
The Application Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172

Part II

Application Model

Chapter 6 Application Model

175

Lifetime Events and Tombstoning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Application Closing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Application Deactivated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Application Deactivated (the Non-Tombstone Case) . . . . . . . . . . . 183
Unhandled Exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Why Is There No App.Exit?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Obscured and Unobscured. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186
Launchers/Choosers and Tombstoning. . . . . . . . . . . . . . . . . . . . . . . 189
User Expectations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189


vii

www.it-ebooks.info


Page Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Page Creation Order. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198

Chapter 7 Navigation State and Storage

199

Navigation and State. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Application and Page State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Detecting Resurrection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Navigation Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209
Using NavigateUri . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Pages in Separate Assemblies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Fragment and QueryString. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
The NavigationMode Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Rerouting Navigation and URI Mappers. . . . . . . . . . . . . . . . . . . . . . 215
Nonlinear Navigation Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Isolated Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Simple Persistence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Persisting the ViewModel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Serialization Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Isolated Storage Helpers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .241

Chapter 8 Diagnostics and Debugging

243

Visual Studio Debugging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Simple Diagnostics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
Setting Up a Diagnostics Pop-Up Window. . . . . . . . . . . . . . . . . . . . 244
Fixed Diagnostics Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Post-Release Diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Persisting Logs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Configurable Diagnostics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Screen Capture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Emulator Console Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Debugging Tombstoning and Lock-Screen. . . . . . . . . . . . . . . . . . . . 263
Debugging MediaPlayer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
viiiContents

www.it-ebooks.info


Device and User Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Windows Phone Performance Counters. . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Memory Diagnostics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
The Device Emulator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Emulator vs. Device. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
XDE Automation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Using the Microsoft Network Monitor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Fiddler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Silverlight Spy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .288

Part III

Extended Services

Chapter 9 Phone Services

291

Phone Hardware. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Launchers and Choosers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Photo Extras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Accelerometer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Reactive Extensions for .NET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Level Starter Kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Shake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Geo-Location. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318

Chapter 10 Media Services

319

Audio and Video Hardware. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
Audio and Video APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .320
Media Playback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
The MediaPlayerLauncher Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
The MediaElement Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
The MediaStreamSource and ManagedMediaHelpers Classes. . . . 323
MediaElement Controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325


ix

www.it-ebooks.info


Audio Input and Manipulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
The SoundEffect and SoundEffectInstance Classes. . . . . . . . . . . . . . 329
Audio Input and the Microphone. . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
The DynamicSoundEffectInstance Class. . . . . . . . . . . . . . . . . . . . . . . 339
Music and Videos Hub. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
The FM Tuner. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348

Chapter 11 Web and Cloud

349

The WebClient Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
WebClient: The DownloadStringAsync Method . . . . . . . . . . . . . . . . 349
WebClient: The OpenReadAsync Method. . . . . . . . . . . . . . . . . . . . . 351
The HttpWebRequest Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Web Browser Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Silverlight and Javascript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Web Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
WCF Data Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
The OData Client and XML Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
JSON-Formatted Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
Bing Maps and Geolocation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
Using the Map Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
Geolocation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Bing Maps Web Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
Deep Zoom (MultiScaleImage). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Windows Azure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Windows Azure Web Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Windows Azure Toolkit for Windows Phone. . . . . . . . . . . . . . . . . . . 390
bitly. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .394
Facebook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Windows Live. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
SkyDrive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .407
xContents

www.it-ebooks.info


Chapter 12 Push Notifications

409

Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Push Notification Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Push Notification Client. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
Additional Server Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
Batching Intervals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
XML Payload. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
Response Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
Additional Client Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Persistent Client Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
The ErrorOccurred Event. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
User Opt-In/Out. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Implementing a Push ViewModel. . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
The Push Notification Server-Side Helper Library. . . . . . . . . . . . . . . . . . . . 437
Common Push Notification Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .443

Chapter 13 Security445
Device Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Application Safeguards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
Application Deployment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
Managed Code Constraints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
Chambers and Capabilities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
Missing Security Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
Data Encryption. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
SDL Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
Threat Modeling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
Static Code Analysis/FxCop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
Web Service Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
Forms Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
Basic Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
SSL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484


xi

www.it-ebooks.info


Push Notification Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
OAuth 1.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
OAuth 2.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
Securing Web Service IDs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494
Implementing Security for the WebBrowser Control. . . . . . . . . . . . . . . . . 496
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .497

Chapter 14 Go to Market

499

Threading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
UI vs. Render Thread, and BitmapCache Mode . . . . . . . . . . . . . . . . 505
UI Layout and ListBoxes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
More UI Performance Tips. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
Non-UI Performance Tips. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
Silverlight Unit Testing Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Certification and Publication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
Updates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Marketplace Reports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Beta Testing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Versions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Light-Up Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
Obfuscation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
Ads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .540
Trial Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
Silverlight Analytics Framework. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .549

xiiContents

www.it-ebooks.info


Part IV

Version 7.5 Enhancements

Chapter 15 Multi-Tasking and Fast App Switching

553

Fast Application Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
Multi-Tasking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
Alarms and Reminders. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558
Alarms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558
Reminders. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
Background Transfer Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
Generic Background Agents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568
Background Audio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
Background Audio: The Main Application. . . . . . . . . . . . . . . . . . . . . 583
Background Audio: The Background Agent. . . . . . . . . . . . . . . . . . . 585
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .587

Chapter 16 Enhanced Phone Services

589

Sensor APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589
Accelerometer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .590
Compass. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .593
Gyroscope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
Motion APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
Camera Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606
Augmented Reality. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610
The Geo Augmented Reality Toolkit . . . . . . . . . . . . . . . . . . . . . . . . . 614
New Photo Extensibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616
Launcher and Chooser Enhancements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
The DeviceStatus and DeviceNetworkInformation classes. . . . . . . . . . . . . 621
Version 7.1.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .626


xiii

www.it-ebooks.info


Chapter 17 Enhanced Connectivity Features

627

Push, Tile, and Toast Enhancements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627
Local Tiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
Pinning Tiles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
Push Enhancements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
Sockets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642
TCP Sockets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
OData Client. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650
Search Extensibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657
App Connect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657
App Instant Answer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .665

Chapter 18 Data Support

667

Local Database and LINQ-to-SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667
Create and Read. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
Update and Delete. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
Schema Updates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677
Associations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681
Isolated Storage Explorer Tool. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684
Performance Considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692
Database Encryption. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695
Encrypting Data and Credentials. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697
Contacts and Calendar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
Sync Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
Service Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705
Database Provisioning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
Code Generation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .710

xivContents

www.it-ebooks.info


Chapter 19 Framework Enhancements

711

Navigation Enhancements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
Frame and Page Navigation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
Backstack Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714
UI Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717
Enhanced Controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718
The ApplicationBar and SystemTray Classes,
and the ProgressIndicator Property . . . . . . . . . . . . . . . . . . . . . . . . . . 723
The Clipboard API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727
32 Bits per Pixel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728
Background Image Decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729
Touch Thread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729
Silverlight 4.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730
Implicit Styles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730
Command Binding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
Data-Binding Enhancements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .744

Chapter 20 Tooling Enhancements

745

Emulator Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745
Debugger Experience. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747
Marketplace Test Kit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749
The Profiler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 754
UserVoice Forums. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 764
Portable Library Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765
Async Framework. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 769
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .772
Index773


xv

www.it-ebooks.info


www.it-ebooks.info


Foreword

S

o, you’re curious about Windows Phone development? Welcome aboard! Whether you’re an
existing Microsoft Silverlight developer wanting to branch out into the mobile space, an existing
mobile developer looking to extend your reach across a second or third ecosystem, a rising star who’s
ready to create the Next Big Thing and take the world by storm, or maybe just a curious phone user
who wants to know what all the “app” fuss is about, Windows Phone is the platform for you.
Getting started with Windows Phone development is free and easy; everything you need to write
apps is just a couple of clicks away. You can have your first app up and running in a matter of minutes,
even if you know next to nothing about Windows Phone development or don’t even own a device. As
your apps become more ambitious and you encounter more complex development issues, a vibrant
developer community on the web is ready and willing to help you out along the way. Mastery of this
platform, with its rich feature set, unique application model, integrated end-to-end experiences, and
burgeoning international marketplace, takes time and effort—and an expertly written guide. Luckily
for you, this book is just such a guide.
The Windows Phone platform stands on the shoulders of giants—giants such as Silverlight, XNA,
Microsoft Visual Studio, and Microsoft Expression Blend—and as we built the platform, we embraced
the power and familiarity that these existing technologies afforded us; our goal was to introduce new
concepts only when strictly necessary to enable new scenarios, and to re-use existing concepts everywhere else. We spent less time re-solving old problems (such as navigation and microphone capture)
and more time tackling new ones so that we could ship a vast array of new phone-specific APIs for
developers to wrap their heads around—cameras, gyroscopes, multi-tasking, phone integration, user
data access, and live tile updates, just to name a few—and Andrew covers all of them (and more!) in
this book.
As you’ve probably heard (and seen), Windows Phone ushered in a new design language for
Microsoft, code-named “Metro.” Adhering closely to this design is critical when building user experiences that will delight and engage your customers. As you would expect, the Windows Phone developer tools give you a big helping hand in this department, providing user interface elements and application templates that “just work” by default. Nevertheless, as the owner of your application’s overall
experience you are ultimately responsible for ensuring it performs optimally, adhering not just to the
graphic design rules, such as “content over chrome,” but also the fast and fluid interaction model that
your customers will come to expect. Throughout this book you’ll find practical examples and guidance that show how to embody the Metro design language in your applications, along with examples
of common pitfalls and how to avoid them—particularly with respect to application performance and
responsiveness, which are key factors in user satisfaction (and hence, app ratings and profitability).


xvii

www.it-ebooks.info


On a more personal note, I was thrilled when Andrew asked me to tech-review this book (although
writing this foreword was more than a little daunting!). As an infrastructure guy at heart, I love building platforms and enabling developers to be successful on top of them, but there are only so many
people you can reach via blogs or conference speaking sessions. I’ve been asked to author books
before, but I've never had the time or inclination to do so. By piggybacking on Andrew’s hard work
with this book, I feel like I’ve made a difference—if only a small one—and that makes me grateful for
the opportunity. I also learned a lot while reviewing this book, and I know that you will, too.
Peter Torr
Program Manager in the
Windows Phone Application
Platform team

xviii  Foreword

www.it-ebooks.info


Introduction

T

he smart phone is increasingly important in people’s daily lives. It is used for a wide variety of
tasks, both work-related and non-work related. People use smart phones to keep up to date
with friends and family, for relaxation, and for entertainment, as well as for viewing documents and
spreadsheets, surfing the Internet, and enriching their lives. There is therefore considerable scope
for building smart phone applications. Windows Phone is not just another smart phone; rather, it is
positioned as an opportunity for developers to build applications that can make a real difference to
people’s lives. The platform has been designed from the ground up to support an all-encompassing,
integrated, and attractive user experience.

Windows Phone 7 Development Internals covers the breadth of application development for the
Windows Phone platform, both the major 7 and 7.1/7.5 versions and the minor 7.1.1 version, and
shows how you can build such compelling and useful applications. You can build applications for
Windows Phone 7.x by using either the Microsoft Silverlight runtime or the XNA runtime. This book
focuses on Silverlight applications. The primary development and design tools are Microsoft Visual
Studio and Microsoft Expression Blend. Here again, this book focuses on Visual Studio.
Each chapter covers a handful of related features. For each feature, the book provides one or more
sample applications and walks you through the significant code (C# and XAML). This will help you
to understand the techniques used and also the design and implementation choices that you have
in each case. Potential pitfalls are called out, as are scenarios in which you can typically make performance or user experience improvements. An underlying theme is to conform not only to the user
interface design guidelines, but also to the notion of a balanced, healthy phone ecosystem.

Who Should Read This Book
This book is intended to help existing developers understand the core concepts, the significant programmable feature areas, and the major techniques in Windows Phone development. The book is tailored for existing Silverlight developers that want to jump into the exciting world of mobile application
developer with the Windows Phone platform. Developers experienced with other mobile platforms
will find this book invaluable in learning the ins and outs of Microsoft’s operating system, but will
likely need additional resources to pick up C# and XAML languages.
The Windows Phone 7 release only supports C#, and although support for Visual Basic was introduced with the 7.1 SDK, this book focuses purely on C# and XAML. The basic architecture of the
platform is covered in Chapter 1, “Vision and Architecture,” and most chapters go deeply into the
internal behavior of the system. This is knowledge that helps to round out your understanding of the
platform, and inform your design decisions, even though, in some cases, the internal details have no
immediate impact on the exposed API.


xix

www.it-ebooks.info


Assumptions
The book assumes that you have a reasonable level of experience of developing in managed code,
specifically in C#. Basic language constructs are not discussed, nor is basic use of Visual Studio, the
project system or the debugger, although more advanced techniques, and phone-specific features
are, of course, explained in detail. You should also have some knowledge of XAML development,
preferably in Silverlight, although Windows Presentation Foundation experience would also be useful
background.
Although many component-level diagrams are presented as high-level abstractions, there are also
many sections that describe the behavior of the feature in question through the use of UML sequence
diagrams. It helps to have an understanding of sequence diagrams, but it is not essential, as they are
fairly self-explanatory.

Who Should Not Read This Book
This book is not intended for use by application designers—if designers are defined as developers
who use Expression Blend—although designers might find it useful to understand some of the issues
facing developers in the Windows Phone application space. The book is also not suitable for XNA
developers because it does not cover game development at all.

Organization of This Book
Windows Phone 7 was first released in October 2010. The first major update, code-named “Mango,”
was released in September 2011. The Mango release includes a wide range of enhancements and
additional features. Note that the user-focused version number for the Mango release (that is, the
product version) is version 7.5; however, the developer-focused number is 7.1 (for both the OS version
and the SDK version). The reason for this slightly confusing numbering situation is that the Mango
release includes improvements across the board—in the operating system, the developer tooling, in
the emulator, in the application platform, in Silverlight itself, and also in the server-side experience
of marketplace, and in ingestion. All of this is Windows Phone, or Windows Phone 7.5. A developer is
normally focused more on the pure technical aspects: the operating system, tooling, and application
platform subset of the overall release, and that is technically the 7.1 release (both SDK and OS).
This book covers all 7.x versions: the original Windows Phone 7 release, the later Windows Phone
7.1 release, and the minor 7.1.1 release. Applications built for version 7 also work without change on
7.1 devices. Note that, while there are still about a million version 7 phones in use, it is safe to assume
that most of these will be upgraded to 7.1 at some point. However, to keep things simple, the first
14 chapters focus on the basic infrastructure, programming model, and the core features that are
common to both versions. Where there are material differences, these are called out, with references
to the later chapter where the 7.1 behavior is explained in detail. Chapter 15, “Multi-Tasking and
Fast App Switching,” onward focuses on the features and platform enhancements that are specific
to version 7.1.
xx  Introduction

www.it-ebooks.info


The 7.1.1 version is a narrowly scoped release intended to support phones with low memory
capabilities (256 MB) for specific target markets. Most developers—and most applications—will not
be affected by this. For the small number that might be affected, the 7.1.1 release provides additional
support for performance tuning and an additional marketplace submission option, as discussed in
Chapter 16, “Enhanced Phone Services.”
It’s also worth reading Chapter 14, “Go To Market” ahead of time. This chapter focuses on the
end-game of bringing your application to market, including tuning the design for performance and
robustness, and marketplace certification. Even before you have a thorough understanding of the
architecture and fundamentals, it is instructive to see what you’ll be aiming for.

Conventions and Features in This Book
This book presents information by using conventions designed to make the information readable and
easy to follow.
■■

■■

■■

■■

■■

■■
■■

■■

In some cases, especially in the early chapters, application code is listed in its entirety. More
often, only the significant code is listed. Wherever code has been omitted for the sake of brevity, this is called out in the listing. In all cases, you can refer to the sample code that accompanies this book for complete listings.
In the XAML listings, attributes that are not relevant to the topic under discussion, and that have
already been explained in previous sections, are omitted. This applies, for example, to Grid.Row,
Grid.Column, Margin, FontSize, and similarly trivial attributes. In this way, you can focus on the
elements and attributes that do actually contribute to the feature at hand, without irrelevant
distractions.
Code identifiers (the names for classes, methods, properties, events, enum values, and so on)
are all italicized in the text.
In the few cases where two or more listings are given with the explicit aim of comparing alternative techniques (or “before” and “after” scenarios), the differences appear in bold.
Boxed elements with labels such as “Note” provide additional information or alternative methods for completing a step successfully.
Text that you type (apart from code blocks) appears in bold.
A plus sign (+) between two key names means that you must press those keys at the same
time. For example, “Press Alt+Tab” means that you hold down the Alt key while you press the
Tab key.
A vertical bar between two or more menu items (for example, File | Close), means that you
should select the first menu or menu item, then the next, and so on.

Introduction  xxi



www.it-ebooks.info


System Requirements
You can build and run the accompanying sample code, or you can create your own solutions from
scratch, following the instructions in the text. In either case, you will need the following hardware and
software to create the sample applications in this book:
■■

■■

■■

■■

■■
■■

■■
■■

Either Windows Vista (x86 and x64) with Service Pack 2, all editions except the Starter Edition,
or Windows 7 (x86 and x64), all editions except the Starter Edition. If you install the Windows
Phone SDK 7.1.1 Update, this also works with the Windows 8 Consumer Preview, although this
is not a supported configuration.
The Windows Phone SDK version 7.0 or 7.1. These are both free downloads that include Visual
Studio 2010 Express Edition and all other standard tools, as listed in Chapter 1. If you install the
SDK version 7.1, you can then also upgrade this with the SDK version 7.1.1. This is an update to
7.1, not a stand-alone install.
Some of the server-side sample projects require Visual Studio Professional, but all of the Windows Phone samples work with Visual Studio Express.
Installing the SDK requires 4 GB of free disk space on the system drive. If you use the profiler
(described in Chapter 20, “Tooling Enhancements”) for an extended period, you will need
considerably more disk space.
4 GB RAM (8 GB recommended).
Windows Phone Emulator requires a DirectX 10 or above capable graphics card with a
WDDM 1.1 driver.
2.6 GHz or faster processor (4GHz or 2.6GHz dual-core, recommended).
Internet connection to download additional software or chapter examples, and for testing
web-related applications.

Depending on your Windows configuration, you might require Local Administrator rights to install
or configure Visual Studio 2010, and to install or configure features such as Internet Information
Services, if not already installed.
For the latest requirements, visit the Windows Phone SDK download page at http://www.microsoft.
com/download/en/details.aspx?id=27570.

xxii  Introduction

www.it-ebooks.info


Code Samples
All of the chapters in this book include multiple sample solutions with which you can interactively try
out new material learned in the main text. All sample projects can be downloaded from the following
page:

http://go.microsoft.com/FWLink/?Linkid=248889
Follow the instructions to download the WP7xDevInternals.zip file.

Installing the Code Samples
Follow these steps to install the code samples on your computer so that you can refer to them while
learning about the techniques that they demonstrate.
1. Unzip the WP7xDevInternals.zip file that you downloaded from the book’s website to any suit-

able folder on your local hard disk. The sample code expands out to nearly 200 MB, and you
will need even more space for the binaries if you choose to build any of the samples.
2. If prompted, review the displayed end-user license agreement. If you accept the terms, select

the accept option, and then click Next.

Note  If the license agreement doesn’t appear, you can access it from the same webpage
from which you downloaded the WP7xDevInternals.zip file.

Using the Code Samples
When you unzip the sample code, this creates a number of subfolders, one for each chapter. Within
each chapter’s subfolder there are further subfolders. In most cases, there is one subfolder per application (or per version of an application), but in some cases, multiple applications are grouped together;
for example, where there is a server-side application as well as a client-side application in the solution.
In keeping with the book's structure, the samples for the first 14 chapters were built as version 7 projects, and the remaining samples were built as version 7.1 projects. However, you can use the version
7.1 (or 7.1.1) SDK for all the sample projects, for all chapters.
All of the samples are complete, fully functioning applications. Note, however, that in some cases,
you might need to update assembly references, depending on where you install the SDK as well as
where you install supplementary libraries and frameworks that don’t ship with the main SDK (for
instance the Silverlight toolkit, Live SDK, Azure toolkit, and so on).
For samples that demonstrate the use of some supplementary framework, you will need to download and install that framework so that you can reference its assemblies. Also note that, in some cases,
this requires a user ID, such as for Bing maps, FaceBook, or Google Analytics, as described in the
relevant sections. In all cases, you can sign up for the ID without charge as of the time of this writing.
Introduction  xxiii



www.it-ebooks.info


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay

×