www.it-ebooks.info ffirs.indd 2 11/27/2012 4:46:33 PM www.it-ebooks.info PROFESSIONAL WINDOWS® 8 PROGRAMMING INTRODUCTION xxv CHAPTER 1 A Glimpse into the Future 1 CHAPTER 2 What Is XAML? 49 CHAPTER 3 Enhancing Your Apps with Control Styles, Data Binding, and Semantic Zoom 79 CHAPTER 4 Windows 8 User Interface Final Touches 121 CHAPTER 5 Application Life Cycle 151 CHAPTER 6 Handling Data, Files, and Networking 181 CHAPTER 7 Sensors 229 CHAPTER 8 Geolocation 249 CHAPTER 9 Application Contracts and Extensions 269 CHAPTER 10 Windows Store Application Architecture 303 CHAPTER 11 Windows Store and Monetization 339 CHAPTER 12 Putting it All Together: Building a Windows Store Application 383 INDEX 449 ffirs.indd 1 11/27/2012 4:46:33 PM www.it-ebooks.info ffirs.indd 2 11/27/2012 4:46:33 PM www.it-ebooks.info PROFESSIONAL Windows ® 8 Programming ffirs.indd 3 11/27/2012 4:46:33 PM www.it-ebooks.info ffirs.indd 4 11/27/2012 4:46:33 PM www.it-ebooks.info PROFESSIONAL Windows ® 8 Programming APPLICATION DEVELOPMENT WITH C# AND XAML Nick Lecrenski Doug Holland Allen Sanders Kevin Ashley ffirs.indd 5 11/27/2012 4:46:34 PM www.it-ebooks.info Professional Windows ® 8 Programming: Application Development with C# and XAML Published by John Wiley & Sons, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2013 by John Wiley & Sons, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-1-118-20570-9 ISBN: 978-1-118-22852-4 (ebk) ISBN: 978-1-118-24082-3 (ebk) ISBN: 978-1-118-26569-7 (ebk) Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specically disclaim all warranties, including without limitation warranties of tness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport .wiley.com. For more information about Wiley products, visit www.wiley.com. Library of Congress Control Number: 2012947694 Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its afliates, in the United States and other countries, and may not be used without written permission. Windows is a registered trademark of Microsoft Corporation. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any product or vendor mentioned in this book. ffirs.indd 6 11/27/2012 4:46:34 PM www.it-ebooks.info This book is dedicated to my remarkably patient family, my wife Kristie and daughters Tabetha and Cheyenne for once again tolerating another year-long book authoring process! —N L Thanks to my wife Wendi and our children Mekella, Jaimee, Andrew, and Jake for their love and support. —D H To Olga, my father Gregory, my mother Vera, and to all of you for reading this book. Enjoy! —K A ffirs.indd 7 11/27/2012 4:46:34 PM www.it-ebooks.info ffirs.indd 8 11/27/2012 4:46:34 PM www.it-ebooks.info [...]... Understanding Windows Store Certification Requirements Summary 375 379 380 381 381 382 CHAPTER 12: PUTTING IT ALL TOGETHER: BUILDING A WINDOWS STORE APPLICATION Welcome to the Final Chapter of the Book Designing the Wrox BookStore App Displaying Wrox Press Books Adding a Wish List Across Devices Diving into the Code 383 383 384 384 386 387 Getting Ready for MVVM Creating Sample Data 388 391 Creating... Styling Controls 79 79 80 Understanding Basic Styling Referencing Styles Across an App Using Microsoft’s Default Styles Data Binding 80 86 88 91 Understanding Basic Data Entry Binding Objects to the User Interface Updating Data with Two-Way Data Binding Data Binding Summary Windows 8 Data Binding Controls ComboBox ListBox ListView GridView Grouped GridView 91 92 96 98 98 98 101 102 106 1 08 Using SemanticZoom... and Decryption Networking 181 182 182 182 184 185 186 188 190 192 192 193 193 197 199 201 203 204 Establishing Socket Connectivity Data Transfers Activating Proximity and Tapping Syndicated Content Accessing Network Information Example: Leaderboard App Summary 204 211 215 221 222 223 2 28 xix www.it-ebooks.info ftoc.indd 19 11/27/2012 4:47:54 PM CONTENTS CHAPTER 7: SENSORS 229 Windows Sensor Platform Hardware... The Game Changer What Makes Windows 8 Different? Understanding Windows 8: The Zune Concept Windows Phone 7 Carry-overs Getting Around in Windows 8 The Login Screen The Start Screen The Search Feature Application Life Cycle Accessing Desktop Mode 1 1 2 3 4 4 5 5 6 7 7 Windows Store App Development Hello Windows 8 Selecting a Language and Default Folders Building a Simple Windows Store App Setting App... flast.indd 30 11/27/2012 4:47:12 PM PROFESSIONAL Windows 8 Programming www.it-ebooks.info flast.indd 31 11/27/2012 4:47:12 PM www.it-ebooks.info flast.indd 32 11/27/2012 4:47:12 PM 1 A Glimpse into the Future WHAT’S IN THIS CHAPTER? ➤ Understanding the Windows 8 difference ➤ Navigating in Windows 8 ➤ How to develop a Windows Store App ➤ Building a Hello Windows App ➤ What type of Windows Store App is best for... for your apps It is an exciting time to be a Microsoft developer, and now that Windows 8 is out in the wild, you’ll see a massive increase in the demand for quality, content-rich apps in the Windows Store These apps must target the PC and tablet, as well as the soon-to-be-released Windows Phone 8 Professional Windows 8 Programming will guide you through all this, ensuring that you have the knowledge... on board and understand some of the vast changes involved in creating Windows- based apps Professional Windows 8 Programming is designed as your guide to all the changes and to get you on the fast track of developing your own apps for the new Windows Store In this book, you learn all about the new development features of Windows 8 and how best to use them in apps for both the PC and tablet You see how... you should be aware that Windows 8 brings massive change in the area of app distribution With the release of Windows 8, developers can now access an online app store where they can easily distribute and sell apps to the massive Windows 8 audience Step by step, this book shows you how to leverage Visual Studio 2012 to prepare your apps for deployment in the Windows Store The new Windows Store gives you... — Learn how to access and make use of the various sensor hardware included on Windows 8 tablet devices ➤ Chapter 8: “Geolocation” — Provides an introduction to Windows 8 support for geolocation services and how to best incorporate this feature in your own apps ➤ Chapter 9: “Application Contracts and Extensions” — Windows 8 introduces a new concept called contracts These enable your app to become part... possible The new convergence of devices and programming support coming from Microsoft for Windows 8 provide opportunities for developers to create innovative solutions, which includes new, improved user interfaces that target multiple devices while using similar or, in many cases, the same underlying code base WHAT MAKES WINDOWS 8 DIFFERENT? Although Windows 8 concepts are now rapidly being applied throughout . in Canada ISBN: 9 78- 1-1 18- 20570-9 ISBN: 9 78- 1-1 18- 2 285 2-4 (ebk) ISBN: 9 78- 1-1 18- 24 082 -3 (ebk) ISBN: 9 78- 1-1 18- 26569-7 (ebk) Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 No. PM www.it-ebooks.info PROFESSIONAL Windows ® 8 Programming ffirs.indd 3 11/27/2012 4:46:33 PM www.it-ebooks.info ffirs.indd 4 11/27/2012 4:46:33 PM www.it-ebooks.info PROFESSIONAL Windows ® 8 Programming. 98 Windows 8 Data Binding Controls 98 ComboBox 98 ListBox 101 ListView 102 GridView 106 Grouped GridView 1 08 Using SemanticZoom 113 Using Custom Controls 116 Summary 119 CHAPTER 4: WINDOWS 8