PUBLISHED BY
Microsoft Press
A Division of Microsoft Corporation
One Microsoft Way
Redmond, Washington 98052-6399
Copyright © 2013 by Charles Petzold
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.
Library of Congress Control Number: 2012955549
ISBN: 978-0-7356-7176-8
Printed and bound in the United States of America.
First Printing
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 ctitious. 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, 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: Devon Musgrave
Developmental Editor: Devon Musgrave
Project Editor: Devon Musgrave
Editorial Production: Waypoint Press
Technical Reviewer: Marc Young
Indexer: Christina Yeager
Cover: Twist Creative
•
Seattle and Joel Panchot
Contents at a Glance
Introduction xv
PART I ELEMENTALS
CHAPTER 1 Markup and Code 3
CHAPTER 2 XAML Syntax 31
CHAPTER 3 Basic Event Handling 69
CHAPTER 4 Presentation with Panels 97
CHAPTER 5 Control Interaction 139
CHAPTER 6 WinRT and MVVM 193
CHAPTER 7 Asynchronicity 221
CHAPTER 8 App Bars and Popups 261
CHAPTER 9 Animation 329
CHAPTER 10 Transforms 377
CHAPTER 11 The Three Templates 449
CHAPTER 12 Pages and Navigation 539
PART II SPECIALTIES
CHAPTER 13 Touch, Etc. 615
CHAPTER 14 Bitmaps 683
CHAPTER 15 Going Native 779
CHAPTER 16 Rich Text 845
CHAPTER 17 Share and Print 893
CHAPTER 18 Sensors and GPS 953
CHAPTER 19 Pen (Also Known as Stylus) 1013
Index 1057
v
Table of Contents
Introduction xv
PART I ELEMENTALS
Chapter 1 Markup and Code 3
The First Project ...................................................3
Graphical Greetings ...............................................9
Variations in Text .................................................13
Media As Well ...................................................22
The Code Alternatives ............................................23
Images in Code ..................................................27
Not Even a Page .................................................29
Chapter 2 XAML Syntax 31
The Gradient Brush in Code .......................................31
Property Element Syntax ..........................................34
Content Properties ...............................................37
The TextBlock Content Property ....................................41
Sharing Brushes (and Other Resources) .............................43
Resources Are Shared .............................................47
Exploring Vector Graphics .........................................48
What do you think of this book? We want to hear from you!
Microsoft is interested in hearing your feedback so we can continually improve our books and learning
resources for you. To participate in a brief online survey, please visit:
microsoft.com/learning/booksurvey