Thông tin tài liệu
Start developing applications
for the Windows Phone quickly and easily
Beginning
Windows Phone 7
Development
Henry Lee
|
Eugene Chuvyrov
Start developing applications
for the Windows Phone quickly and easily
Beginning
Windows Phone 7
Development
Henry Lee
|
Eugene Chuvyrov
Start developing applications
for the Windows Phone quickly and easily
Beginning
Windows Phone 7
Development
Henry Lee
|
Eugene Chuvyrov
Start developing applications
for the Windows Phone quickly and easily
Beginning
Windows Phone 7
Development
Henry Lee
|
Eugene Chuvyrov
Start developing applications
for the Windows Phone quickly and easily
Beginning
Windows Phone 7
Development
Henry Lee
|
Eugene Chuvyrov
Start developing applications
for the Windows Phone quickly and easily
Beginning
Windows Phone 7
Development
Henry Lee
|
Eugene Chuvyrov
Start developing applications
for the Windows Phone quickly and easily
Beginning
Windows Phone 7
Development
Henry Lee
|
Eugene Chuvyrov
Start developing applications
for the Windows Phone quickly and easily
Beginning
Windows Phone 7
Development
Henry Lee
|
Eugene Chuvyrov
Download from Wow! eBook <www.wowebook.com>
i
Beginning Windows
Phone 7 Development
■ ■ ■
Henry Lee
and
Eugene Chuvyrov
ii
Beginning Windows Phone 7 Development
Copyright © 2010 by Henry Lee & Eugene Chuvyrov
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system,
without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-4302-3216-2
ISBN-13 (electronic): 978-1-4302-3217-9
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
President and Publisher: Paul Manning
Lead Editor: Ewan Buckingham
Development Editor: John Osborn
Technical Reviewer: Stefan Turalski
Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick,
Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank
Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh
Coordinating Editor: Jennifer L. Blackwell
Copy Editor: Mary Ann Fugate
Compositor: MacPS, LLC
Indexer: Brenda Miller
Artist: April Milne
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th
Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com.
For information on translations, please e-mail rights@apress.com, or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–
eBook Licensing web page at www.apress.com/info/bulksales.
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has
been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any
person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the
information contained in this work.
The source code for this book is available to readers at www.apress.com.
iii
To Erica, my beautiful wife, for her love and support.
Thank you for always being there for me.
—Henry Lee
To Marianna—my friend, my wife, my muse—and to
my parents for their gift of unconditional love.
—Eugene Chuvyrov
iv
Contents at a Glance
■Contents v
■About the Authors xvi
■About the Technical Reviewer xvii
■Acknowledgments xviii
■Introduction xix
Part 1: The Essentials of Windows Phone 7 Application Development 1
■Chapter 1: Introducing Windows Phone 7 and the Windows Phone Platform 3
■Chapter 2: Building Windows Phone 7 Applications 15
■Chapter 3: Using Cloud Services As Data Stores 35
■Chapter 4: Catching and Debugging Errors 97
■Chapter 5: Packaging, Publishing, and Managing Applications 121
Part 2: Using Windows Phone 7 Technologies 139
■Chapter 6: Working with the Accelerometer 141
■Chapter 7: Application Bar 161
■Chapter 8: WebBrowser Control 179
■Chapter 9: Working with Controls and Themes 193
■Chapter 10: Integrating Applications with the Windows Phone OS 211
■Chapter 11: Creating Trial Applications 229
■Chapter 12: Internationalization 251
■Chapter 13: Isolated Storage 267
■Chapter 14: Using Location Services 285
■Chapter 15: Media 311
■Chapter 16: Working with the Camera and Photos 329
■Chapter 17: Push Notifications 347
■Chapter 18: Reactive Extensions for .NET 383
■Chapter 19: Security 413
■Index 441
v
Contents
■Contents at a Glance iv
■About the Authors xvi
■About the Technical Reviewer xvii
■Acknowledgments xviii
■Introduction xix
Part 1: The Essentials of Windows Phone 7 Application Development 1
■Chapter 1: Introducing Windows Phone 7 and the
Windows Phone Platform 3
Windows Phone Overview 5
Windows Phone Hardware Specifications 5
Windows Phone Application Platform 7
Silverlight for Windows Phone 7
XNA for Windows Phone 8
Tools 8
Cloud Services 11
Metro Design 12
Application Development Life Cycle 12
Summary 14
■Chapter 2: Building Windows Phone 7 Applications 15
Preparing Your Development Machine 15
Building Your First Windows Phone 7 Application 15
Creating a Windows Phone Project 16
■ CONTENTS
vi
Using Your First Windows Phone Silverlight Controls 18
Writing Your First Windows Phone Code 22
Running Your First Silverlight Windows Phone Application 23
Customizing Your First Windows Phone Application 25
Styling Your Application 28
Summary 34
■Chapter 3: Using Cloud Services As Data Stores 35
Introducing the MVVM Pattern 36
Introducing Microsoft Azure and SQL Azure 37
Creating a Cloud Database 37
Creating an SQL Azure Database 38
Creating a Database in SQL Azure 47
Creating a Cloud Service to Access the Cloud Database 50
Creating a Windows Azure Project 51
Generating an Object Model to Access the Cloud Database 52
Implementing a WCF Service to Access the SQL Azure Database 57
Building a Phone Client to Access a Cloud Service 64
Creating a Windows Phone Project 64
Building the User Interface 65
Coding MainPage 71
Coding the BoolToVisibilityConvert 72
Adding Reference to NotepadService 74
Coding NotepadViewModel 75
Testing the Application Against NotepadService Deployed Locally 82
Deploying the Service to Windows Azure 83
Testing the Notepad Application Against NotepadService Azure Service 94
Summary 95
■Chapter 4: Catching and Debugging Errors 97
Debugging Application Exceptions 97
Debugging Page Load Exceptions 98
■ CONTENTS
vii
Debugging a Web Service Exception 102
Testing the Application 107
Registering a Windows Phone Device for Debugging 107
Handling Device Exceptions 113
Creating the CatchDeviceExceptionDemo Project 114
Building the User Interface 115
Coding the Application 117
Testing the Finished Application 119
Summary 119
■Chapter 5: Packaging, Publishing, and Managing Applications 121
Windows Phone Application Publishing Lifecycle 121
Windows Phone Application Certification Requirements 123
Application Policies 123
Content Policies 125
Application Submission Validation Requirements 125
Application Certification Requirements 126
Submitting Your First Windows Phone Application to
the Windows Phone Marketplace 128
Package the application 128
Submit the application 129
Updating your application 136
Finding your application in the Marketplace 137
Summary 138
Part 2: Using Windows Phone 7 Technologies 139
■Chapter 6: Working with the Accelerometer 141
Understanding Orientation and Movement 141
Calculating Distance 144
Calculating Pitch and Roll 144
Introducing SDK Support for Accelerometers 146
■ CONTENTS
viii
Retrieving Accelerometer Data 146
Creating the CaptureAccelerometerData Project 147
Building the User Interface 148
Coding the Application 150
Testing the Finished Application 152
Using Accelerometer Data to Move a Ball 153
Creating the MoveBall Project 154
Building the User Interface 155
Coding the Application 157
Testing the Finished Application 159
Summary 159
■Chapter 7: Application Bar 161
Introducing the Application Bar 162
Adding an Application Bar to a Windows Phone 7 Application 163
Adding Images for Use with Application Bar Buttons 164
Adding a Global Application Bar Using XAML 166
Adding a Local Application Bar Using XAML 167
Adding Menu Items 168
Adding an Application Bar Using Managed Code 169
Wiring Up Events to an Application Bar 171
Adding “Glue” Code and a “Worker Function” to the Add Button 171
Reacting to Add Button Events 172
Reacting to Save Button Events 175
Reacting to Menu Events 175
Adding Event Handlers with XAML 176
Summary 177
■Chapter 8: WebBrowser Control 179
Introducing the WebBrowser Control 179
Adding a WebBrowser Control 180
[...]... this book • Windows Phone Developer Tools RTW (http://download.microsoft.com/download/1 /7/ 7/ 177 D6AF8-17FA-40E7-AB5300B7CED3 172 9/vm_web.exe) • Zune Software (www.zune.net/en-us/products/software/download/) • Windows Phone 7 UI Design and Interface Guide (http://go.microsoft.com/fwlink/?LinkID=183218) • Windows Phone 7 Marketplace Certification Requirements (http://go.microsoft.com/?linkid= 973 0558) • Microsoft... application, getting familiar with development tools like Visual Studio for Windows Phone and Microsoft Expression Blend for Windows Phone, and learning to interact with the Windows Phone developer portal, rather than special phone features such as the GPS radio or accelerometer We’ll turn to those in Part 2 2 CHAPTER 1 ■■■ Introducing Windows Phone 7 and the Windows Phone Platform This is an exciting... the Windows Phone 7 Training Kit that might contain how-tos on specific technology you are having problems with You can go to http://forums.silverlight.net/forums/63.aspx, where you can ask about Silverlight for Windows Phone related questions, or if you have other related Windows Phone questions, you can visit http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series Also the Windows Phone development. .. business oriented applications 7 CHAPTER 1 ■ INTRODUCING WINDOWS PHONE 7 AND THE WINDOWS PHONE PLATFORM XNA for Windows Phone Like Silverlight, XNA is not a new technology XNA is used in creating Xbox games, using managed code It is a natural choice for creating games since Windows Phone has Xbox LIVE integration, allowing XNAbased Xbox games to be easily posted over to Windows Phone The only thing Xbox... CHAPTER 1 ■ INTRODUCING WINDOWS PHONE 7 AND THE WINDOWS PHONE PLATFORM Figure 1–4 Microsoft Expresion Blend 4 for Windows Phone Windows Phone Emulator The Windows Phone emulator as seen in Figure 1–5 is integrated to Visual Studio that simulates a real device However, there are things you cannot do in the emulator, like test the accelerometer, GPS, compass, FM radio, SMS, e-mail, phone calling, contact... what Windows Phone has to offer to developers like you 4 CHAPTER 1 ■ INTRODUCING WINDOWS PHONE 7 AND THE WINDOWS PHONE PLATFORM Windows Phone Overview Microsoft Windows Phone is a great consumer phone because it has all of the features to which users have become accustomed with the Apple iPhone and Android-powered smartphones, like the Motorola Droid and HTC Incredible These features include multitouch,... .214 Working with the Windows Phone 7 Application Life Cycle 215 Observing Application Life Cycle Events 216 Managing Application State 220 Best Practices for Managing the Application Life Cycle on the Windows Phone 7 OS .225 Download from Wow! eBook Windows Phone 7 Hubs 225 Summary 2 27 ■Chapter 11: Creating Trial... Eugene Chuvyrov: echuvyrov@msn.com xx PART 1 ■■■ The Essentials of Windows Phone 7 Application Development In Part 1, you will be introduced to the full development life cycle of a Windows Phone 7 application: installing and understanding the tools and SDKs; deploying database and service layers to the Azure cloud; creating a connected Windows Phone application; debugging and catching errors; and finally... information on the release of these phones at www.microsoft.com/windowsphone/enus/buy /7/ phones.aspx In the next section, you will learn how the software behind these great consumer phones also provides a great development platform for developers Windows Phone Application Platform Microsoft did not invent any new languages or frameworks for the Windows Phone application platform The company simply adapted its... Saving Photos to the Phone .336 Integrating Your Application with Windows Phone 7 338 Using Extras to Launch an Application .338 Using Share to Upload PhotoCapture Snapshots to TwitPic 340 Summary 3 47 ■Chapter 17: Push Notifications 3 47 Understanding Push Notifications 3 47 Toast Notifications .3 47 Tile Notifications . of Windows Phone 7 Application Development 1
■Chapter 1: Introducing Windows Phone 7 and the
Windows Phone Platform 3
Windows Phone Overview 5
Windows. of Windows Phone 7 Application Development 1
■Chapter 1: Introducing Windows Phone 7 and the Windows Phone Platform 3
■Chapter 2: Building Windows Phone
Ngày đăng: 06/03/2014, 07:20
Xem thêm: Windows Phone 7 Development pptx, Windows Phone 7 Development pptx