Sams Teach Yourself Windows® Phone 7 Application Development in 24 Hours
Total Page:16
File Type:pdf, Size:1020Kb
Scott Dorman Kevin Wolf Nikita Polyakov Joe Healy SamsTeachYourself Windows® Phone 7 Application Development in Hours24 800 East 96th Street, Indianapolis, Indiana, 46240 USA Sams Teach Yourself Windows® Phone 7 Application Development Editor-in-Chief in 24 Hours Greg Wiegand Copyright © 2012 by Pearson Education Executive Editor All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without Neil Rowe written permission from the publisher. No patent liability is assumed with respect to the use of Acquisitions Editor the information contained herein. Although every precaution has been taken in the preparation of Brook Farling this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein. Development ISBN-13: 978-0-672-33539-6 Editor ISBN-10: 0-672-33539-5 Mark Renfrow Library of Congress Cataloging-in-Publication Data Managing Editor Sams teach yourself Windows Phone 7 application development in 24 hours / Scott Dorman ... [et al.]. Kristy Hart p. cm. Project Editor Includes index. Betsy Harris ISBN-13: 978-0-672-33539-6 Copy Editor ISBN-10: 0-672-33539-5 Karen Annett 1. Windows phone (Computer file) 2. Application software—Development. 3. Smartphones— Programming. 4. Mobile computing. I. Dorman, Scott, 1973- II. Title: Windows Phone 7 applica- Senior Indexer tion development in 24hours. Cheryl Lenser QA76.76.A65S254 2012 Proofreader 004.16’7—dc23 Paula Lowell 2012007173 Printed in the United States of America Technical Editor First Printing April 2012 Richard Bailey Trademarks Publishing All terms mentioned in this book that are known to be trademarks or service marks have been Coordinator appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use Cindy Teeters of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Book Designer Warning and Disclaimer Gary Adair Every effort has been made to make this book as complete and as accurate as possible, but no Senior Compositor warranty or fitness is implied. The information provided is on an “as is” basis. The authors and the publisher shall have neither liability nor responsibility to any person or entity with respect to Gloria Schurick any loss or damages arising from the information contained in this book. Bulk Sales Sams Publishing offers excellent discounts on this book when ordered in quantity for bulk pur- chases or special sales. For more information, please contact U.S. Corporate and Government Sales 1-800-382-3419 [email protected] For sales outside of the U.S., please contact International Sales [email protected] Contents at a Glance Part I: Fundamentals HOUR 1 Introducing Windows Phone 7 ......................................................1 2 Considerations for Desktop Developers ..........................................21 3 Choosing an Application Framework ............................................31 4 Learning Silverlight Basics ...........................................................45 5 Understanding Page-Based Navigation ..........................................73 6 Using the Sensors .......................................................................87 Part II: Developing Applications with Silverlight HOUR 7 Working with the GPS and the Bing Map Control .............................99 8 Developing Finger-Friendly Applications ......................................111 9 Consuming Web Data Services ...................................................129 10 Working with REST, Syndication Feeds, and OData ........................141 11 Integrating with Windows Phone Hubs ........................................159 12 Integrating with Microsoft Services ..............................................177 13 Performance and Debugging ......................................................191 14 Understanding Push Notification Services .....................................207 15 Understanding Live Tiles and Toast Notifications ...........................217 16 Working with Data ...................................................................231 Part III: Developing Games with the XNA Framework HOUR 17 Introduction to XNA Programming .............................................249 18 Building a Simple Game ............................................................263 19 Adding Polish to Your Game ......................................................281 iv Sams Teach Yourself Windows Phone 7 Application Development in 24 Hours Part IV: Diving Deeper HOUR 20 Internationalizing Your Application ............................................293 21 Working with Phone Internals ....................................................309 22 Being a Good Mobile Citizen ......................................................325 23 Distributing Applications with the Marketplace .............................343 24 Marketing and Selling Your Application .......................................359 Resources ................................................................................371 Index .....................................................................................373 Table of Contents Introduction xvii Audience and Organization ................................................................xviii Conventions Used In This Book ............................................................xix Closing Thoughts................................................................................xix Part I: Fundamentals HOUR 1: Introducing Windows Phone 7 1 Experiencing Life in Motion ....................................................................2 Ensuring a Common Foundation ............................................................3 Introducing the Application Platform ......................................................6 Introducing Metro................................................................................11 Summary ..........................................................................................18 Q&A..................................................................................................19 HOUR 2: Considerations for Desktop Developers 21 Understanding the Requirements............................................................21 Identifying Users and Their Mobile Needs ................................................22 Getting Data for Your Application ..........................................................25 Building the User Interface ....................................................................27 Summary ..........................................................................................29 Q&A..................................................................................................29 Workshop ..........................................................................................29 HOUR 3: Choosing an Application Framework 31 Introducing the Application Frameworks ................................................31 Understanding Silverlight......................................................................32 Understanding the XNA Framework........................................................37 vi Sams Teach Yourself Windows Phone 7 Application Development in 24 Hours Summary ..........................................................................................41 Q&A..................................................................................................42 Workshop ..........................................................................................43 Exercise ..............................................................................................43 HOUR 4: Learning Silverlight Basics 45 Understanding Silverlight......................................................................45 Silverlight Coding Fundamentals............................................................46 Exploring Silverlight Controls ................................................................49 Understanding Data Binding ................................................................62 Summary ..........................................................................................70 Q&A..................................................................................................70 HOUR 5: Understanding Page-Based Navigation 73 Introducing the Page Navigation Model ..................................................74 Using the Navigation Service ................................................................75 Working with Page Navigation Events ....................................................79 Passing Data with the Navigation Context ..............................................82 Summary ..........................................................................................83 Q&A..................................................................................................83 Workshop ..........................................................................................84 Exercise ..............................................................................................85 HOUR 6: Using the Sensors 87 Working with the Accelerometer ............................................................87 Using the Compass ..............................................................................91 Responding