www.it-ebooks.info
www.it-ebooks.info
Exam Ref 70-484:
Essentials of Developing
Windows Store Apps
Using C#
Indrajit Chakrabarty
www.it-ebooks.info
Published with the authorization of Microsoft Corporation by:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, California 95472
Copyright © 2013 by O'Reilly Media, Inc.
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-7684-8
1 2 3 4 5 6 7 8 9 QG 8 7 6 5 4 3
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
Please tell us what you think of this book at />Microsoft and the trademarks listed at 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: Box Twelve Communications, Inc.
Production Editor: Kristen Borg
Editorial Production: Box Twelve Communications, Inc.
Technical Reviewer: Damien Foggon
Copyeditor: Box Twelve Communications, Inc.
Indexer: Box Twelve Communications, Inc.
Cover Design: Twist Creative • Seattle
Cover Composition: Ellie Volckhausen
Illustrator: Rebecca Demarest
www.it-ebooks.info
This book is dedicated to Tiya and Liana, the best gifts of my life.
www.it-ebooks.info
www.it-ebooks.info
Contents at a glance
Introductionxvii
Preparing for the exam
xx
Chapter 1
Design Windows Store apps
1
Chapter 2
Develop Windows Store apps
Chapter 3
Create the user interface
143
Chapter 4
Program the user interaction
225
Chapter 5
Manage security and data
305
65
Index401
www.it-ebooks.info
www.it-ebooks.info
Contents
Introductionxvii
Microsoft certifications
xvii
Acknowledgmentsxviii
Errata & book support
xviii
We want to hear from you
xix
Stay in touch
xix
Preparing for the exam
xx
Chapter 1 Design Windows Store apps
1
Objective 1.1: Design the UI layout and structure . . . . . . . . . . . . . . . . . . . . . 1
Evaluating the conceptual design and deciding how the
UI will be composed
2
Designing for the inheritance and reuse of visual elements
4
Designing for accessibility
6
Deciding when custom controls are needed
9
Objective summary
11
Objective review
11
Objective 1.2: Design for separation of concerns (SOC) . . . . . . . . . . . . . . . 12
Planning the logical layers of your solution to meet app
requirements13
Designing loosely coupled layers
14
Incorporating WinMD components
15
Objective summary
17
Objective review
17
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:
www.microsoft.com/learning/booksurvey/
vii
www.it-ebooks.info
Objective 1.3: Apply the MVVM pattern to your
app design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Designing and implementing the appropriate data
model to support business entities
19
Designing a viewmodel to support the view based on
your model
25
Developing a view to meet data-binding requirements
25
Creating viewmodels using NotifyPropertyChanged,
ObservableCollection, and CollectionViewSource
27
Objective summary
31
Objective review
31
Objective 1.4: Design and implement Process Lifetime
Management (PLM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Choosing a state management strategy
33
Handling the Suspending event and preparing for app
termination35
Handling the Resuming event
38
Handling the OnActivated events
38
Checking the ActivationKind and previous state
41
Objective summary
44
Objective review
44
Objective 1.5: Plan for an app deployment. . . . . . . . . . . . . . . . . . . . . . . . . . 45
Planning a deployment based on Windows Store app
certification requirements
45
Preparing an application manifest
48
Signing an application
53
Planning the requirements for an enterprise deployment
54
Objective summary
55
Objective review
56
Chapter summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Answers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
viii
Objective 1.1: Thought experiment
58
Objective 1.1: Review
58
Objective 1.2: Thought experiment
59
Objective 1.2: Review
59
Contents
www.it-ebooks.info
Objective 1.3: Thought experiment
60
Objective 1.3: Review
60
Objective 1.4: Thought experiment
61
Objective 1.4: Review
61
Objective 1.5: Thought experiment
62
Objective 1.5: Review
62
Chapter 2 Develop Windows Store apps
65
Objective 2.1: Access and display contacts. . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Calling the ContactPicker class
66
Filtering which contacts to display
69
Selecting specific contact data
70
Displaying a set number of contacts
72
Creating and modifying contact information
74
Objective summary
76
Objective review
76
Objective 2.2: Design for charms and contracts. . . . . . . . . . . . . . . . . . . . . . 77
Choosing the appropriate charm based on app requirements
78
Designing your app in a charm-aware and contractaware manner
82
Configuring the app manifest for correct permissions
91
Objective summary
93
Objective review
94
Objective 2.3: Implement search. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Providing and constraining search within an app
95
Providing search result previews
100
Providing search suggestions using the SearchPane class
102
Implementing activation from within search
107
Searching for and launching other apps
108
Objective summary
109
Objective review
110
Objective 2.4: Implement Share in an app. . . . . . . . . . . . . . . . . . . . . . . . . . 110
Using the DataTransferManager class to share data with
other apps
111
Contents
www.it-ebooks.info
ix
Accepting sharing requests by implementing activation
within the Share charm
114
Limiting the scope of sharing using the DataPackage object
120
Implementing in-app share outside the Share charm
122
Objective summary
123
Objective review
123
Objective 2.5: Manage app settings and preferences . . . . . . . . . . . . . . . . 124
Choosing which app features are accessed in AppSettings
124
Adding entry points for AppSettings in the Settings window
125
Creating settings flyouts using the Popup control
127
Adding settings to Popup
129
Storing and retrieving settings from the roaming app
data store
130
Objective summary
132
Objective review
133
Chapter summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Answers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Objective 2.1: Thought experiment
135
Objective 2.1: Review
135
Objective 2.2: Thought experiment
136
Objective 2.2: Review
136
Objective 2.3: Thought experiment
137
Objective 2.3: Review
138
Objective 2.4: Thought experiment
138
Objective 2.4: Review
139
Objective 2.5: Thought experiment
140
Objective 2.5: Review
140
Chapter 3 Create the user interface
143
Objective 3.1: Create layout aware apps to handle view states. . . . . . . . 143
x
Handling view state events from ViewStateManager
144
Choosing between style patterns for different view states
151
Setting up app orientation in the manifest
154
Objective summary
156
Objective review
156
Contents
www.it-ebooks.info
Objective 3.2: Implement layout controls. . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Implementing the Grid control to structure the app layout
158
Setting the number of rows/columns and size
163
Enabling scroll and zoom capabilities in layout controls
166
Managing text flow and presentation
170
Objective summary
177
Objective review
177
Objective 3.3: Design and implement the app bar. . . . . . . . . . . . . . . . . . . 178
Determining what to put on the app bar based on app
requirements179
Designing the placement of controls on the app bar
182
Styling and positioning app bar items
184
Handling AppBar events
186
Objective summary
188
Objective review
188
Objective 3.4: Design and implement data presentation . . . . . . . . . . . . . 189
Choosing and implementing data controls to meet app
requirements190
Creating data templates to meet app requirements
197
Objective summary
200
Objective review
201
Objective 3.5: Create and manage XAML styles and templates. . . . . . . . 202
Implementing and extending styles and templates
203
Implementing gradients
209
Modifying styles based on event and property triggers
210
Creating shared resources and themes
212
Objective summary
214
Objective review
214
Chapter summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Answers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Objective 3.1: Thought experiment
217
Objective 3.1: Review
217
Objective 3.2: Thought experiment
218
Objective 3.2: Review
218
Contents
www.it-ebooks.info
xi
Objective 3.3: Thought experiment
219
Objective 3.3: Review
220
Objective 3.4: Thought experiment
221
Objective 3.4: Review
221
Objective 3.5: Thought experiment
222
Objective 3.5: Review
222
Chapter 4 Program the user interaction
225
Objective 4.1: Create and manage tiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Creating and updating tiles and tile contents
226
Creating and updating badges using the
TileUpdateManager class
236
Responding to notification requests
237
Choosing an appropriate tile update schedule based on
app requirements
244
Objective summary
247
Objective review
248
Objective 4.2: Notify users by using toast. . . . . . . . . . . . . . . . . . . . . . . . . . 249
Enabling an app for toast notifications
249
Populating toast notifications with images and text using the ToastUpdateManager class
252
Controlling toast duration
255
Playing sounds with toast notifications
256
Responding to toast events
257
Objective summary
261
Objective review
262
Objective 4.3: Manage input devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
xii
Capturing gesture library events
264
Creating custom gesture recognizers
272
Listening to mouse events or touch gestures
274
Managing stylus input and inking
276
Objective summary
278
Objective review
278
Contents
www.it-ebooks.info
Objective 4.4: Design and implement navigation in an app. . . . . . . . . . . 280
Designing navigation to meet app requirements
280
Working with navigation events, properties, and functions
286
Using Semantic Zoom in your app
292
Objective summary
295
Objective review
296
Chapter summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Answers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Objective 4.1: Thought experiment
298
Objective 4.1: Review
298
Objective 4.2: Thought experiment
299
Objective 4.2: Review
300
Objective 4.3: Thought experiment
301
Objective 4.3: Review
301
Objective 4.4: Thought experiment
302
Objective 4.4: Review
303
Chapter 5 Manage security and data
305
Objective 5.1: Choose an appropriate data access strategy. . . . . . . . . . . 306
Choosing the appropriate data access strategy based
on app requirements
306
Managing application data
316
Storing and retrieving data from a remote location
328
Objective summary
330
Objective review
330
Objective 5.2: Retrieve data remotely. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Using HttpClient to retrieve data from web services
332
Setting the appropriate HTTP verb for REST
337
Consuming SOAP/WCF services
340
Using WebSockets for bidirectional communication
341
Handling the progress of data requests
347
Objective summary
350
Objective review
350
Contents
www.it-ebooks.info
xiii
Objective 5.3: Implement data binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Choosing and implementing data-bound controls
353
Binding collections to items controls
356
Implementing the IValueConverter interface
360
Creating and setting dependency properties
361
Validating user input
364
Enabling data filtering, grouping, and sorting in the
user interface
367
Objective summary
369
Objective review
370
Objective 5.4: Manage Windows Authentication. . . . . . . . . . . . . . . . . . . . 371
Retrieving a user’s roles and claims
372
Storing and retrieving credentials with the PasswordVault class 374
Implementing the CredentialPicker class
376
Objective summary
380
Objective review
380
Objective 5.5: Manage web authentication. . . . . . . . . . . . . . . . . . . . . . . . . 382
Using the Windows.Security.Authentication.Web namespace
382
Implementing the WebAuthenticationBroker class
384
Setting up OAuth2 for authentication
386
Setting up single sign-on (SSO)
387
Implementing the CredentialPicker class
388
Implementing credential roaming
389
Objective summary
389
Objective review
389
Chapter summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
Answers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
xiv
Objective 5.1: Thought experiment
392
Objective 5.1: Review
392
Objective 5.2: Thought experiment
393
Objective 5.2: Review
394
Objective 5.3: Thought experiment
395
Objective 5.3: Review
396
Contents
www.it-ebooks.info
Objective 5.4: Thought experiment
397
Objective 5.4: Review
397
Objective 5.5: Thought experiment
398
Objective 5.5: Review
399
Index401
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:
www.microsoft.com/learning/booksurvey/
Contents
www.it-ebooks.info
xv
www.it-ebooks.info
Introduction
The Microsoft 70-484 certification exam tests your knowledge of designing and developing Windows Store apps. Readers are assumed to be experienced Microsoft Windows-based
application developers, including two or more years creating and modifying touch-enabled
interfaces.
The exam expects you to be familiar with the high-level concepts required to build such
apps, including C# and the Microsoft Visual Studio 2012 environment. Therefore, this book
adopts a high-level approach to teaching application design, and provides numerous code
samples that illustrate concepts without step-by-step details of building a Windows Store app
in Visual Studio. You should be able to design and build Windows Store apps on your own,
while using this book to study for the exam.
Success on the 70-484 exam will prove your knowledge and experience in designing and
developing Windows Store apps using Microsoft technologies. This exam guide reviews the
concepts described in the exam objectives, such as:
■■
Designing Windows Store apps
■■
Developing Windows Store apps
■■
Creating the user interface
■■
Programming the user interaction
■■
Managing security and data
This book covers every exam objective, but it does not cover every exam question. Only
the Microsoft exam team has access to the exam questions themselves and Microsoft regularly adds new questions to the exam, making it impossible to cover specific questions. You
should consider this book a supplement to your relevant real-world experience and other
study materials. If you encounter a topic in this book that you do not feel completely comfortable with, use the links you’ll find in text to find more information and take the time to
research and study the topic. Great information is available on MSDN, TechNet, and in blogs
and forums.
Microsoft certifications
Microsoft certifications distinguish you by proving your command of a broad set of skills and
experience with current Microsoft products and technologies. The exams and corresponding
certifications are developed to validate your mastery of critical competencies as you design
and develop, or implement and support, solutions with Microsoft products and technologies
xvii
www.it-ebooks.info
both on-premise and in the cloud. Certification brings a variety of benefits to the individual
and to employers and organizations.
MORE INFO ALL MICROSOFT CERTIFICATIONS
For information about Microsoft certifications, including a full list of available certifications, go to />
Acknowledgments
I would like to thank Jeff Riley, Box Twelve Communications, for choosing me to write this
book, and Kim Lindros for her work as the developmental editor. Kim’s thorough reviews immensely improved the quality of the book. I would like to thank Damien Foggon, the technical reviewer, for his comments and attention to detail while reviewing the book.
I would also like to thank Carole Jelen, Waterside Publications, for the initial discussions
and help in setting up the project, and David Wall (www.davidwall.com) for introducing me to
Carole and for helping me complete other projects while this book was under way.
Finally, I must thank Tiya and Liana for their understanding and support while I was writing
the book through the summer holidays.
Errata & book support
We’ve made every effort to ensure the accuracy of this book and its companion content.
Any errors that have been reported since this book was published are listed on our Microsoft
Press site at oreilly.com:
/>If you find an error that is not already listed, you can report it to us through the same
page.
If you need additional support, email Microsoft Press Book Support at
xviii Introduction
www.it-ebooks.info
Please note that product support for Microsoft software is not offered through the addresses above.
We want to hear from you
At Microsoft Press, your satisfaction is our top priority, and your feedback our most valuable
asset. Please tell us what you think of this book at:
/>The survey is short, and we read every one of your comments and ideas. Thanks in advance for your input!
Stay in touch
Let’s keep the conversation going! We’re on Twitter: />
Introduction xix
www.it-ebooks.info
Preparing for the exam
Microsoft certification exams are a great way to build your resume and let the world know
about your level of expertise. Certification exams validate your on-the-job experience and
product knowledge. While there is no substitution for on-the-job experience, preparation
through study and hands-on practice can help you prepare for the exam. We recommend
that you round out your exam preparation plan by using a combination of available study
materials and courses. For example, you might use this Exam Ref and another study guide for
your "at home" preparation, and take a Microsoft Official Curriculum course for the classroom
experience. Choose the combination that you think works best for you.
Note that this Exam Ref is based on publically available information about the exam and
the author's experience. To safeguard the integrity of the exam, authors do not have access to
the live exam.
xx Preparing for the exam
www.it-ebooks.info
CHAPTER 1
Design Windows Store apps
The launch of Windows 8 was accompanied with the introduction of Windows Runtime
(WinRT), a new framework for building touch-friendly user interfaces (UIs) for Windows
Store applications (apps). With WinRT, Windows Presentation Foundation (WPF) and Silverlight developers could leverage their existing XAML and C#/VB.NET skills to build Windows
Store apps. In addition to the new framework and an accompanying toolset, Microsoft
introduced a new design language called “Microsoft design style.”
The conceptual design of an application is the first stage of designing an application.
In the conceptual design, you focus on a set of ideas and concepts about what your app
should do, how it will behave when users interact with it, and what it should look like. A
well-designed application has logical layers loosely coupled with a UI, which is used for
presenting the data. Separating logic from presentation enables the application to be enhanced or updated without changing the conceptual design.
You can use design patterns such as Model-View-ViewModel (MVVM) to develop maintainable and extensible applications. Data and state preservation across various states of
an application is important in providing a great user experience. After you build and test
your application, you need to prepare the app for Windows Store certification. Microsoft
provides a set of requirements to help you during the app certification process and deployment in the Windows Store.
Objectives in this chapter:
■■
Objective 1.1: Design the UI layout and structure
■■
Objective 1.2: Design for separation of concerns (SOC)
■■
Objective 1.3: Apply the MVVM pattern to your app design
■■
Objective 1.4: Design and implement Process Lifetime Management (PLM)
■■
Objective 1.5: Plan for an app deployment
Objective 1.1: Design the UI layout and structure
The primary form of interaction with a Windows Store app by its users is through the user
interface (UI). Microsoft design style consists of a set of principles that provide a consistent, elegant, and compelling user experience in Windows Store apps. You should plan
and design Windows Store app UIs with these principles as a reference. The UI should be
1
www.it-ebooks.info
composed of visual elements and controls, with a clear hierarchy in their layout. You should
also consider users with disabilities and preferences, and design your app for accessibility.
Reusing UI code in multiple applications will help you to rapidly build Windows Store apps;
therefore, you should consider building custom controls and using them in your apps.
This objective covers how to:
■■
Evaluate the conceptual design and decide how the UI will be composed
■■
Design for the inheritance and re-use of visual elements
■■
Design for accessibility
■■
Decide when custom controls are needed
Evaluating the conceptual design and deciding how the UI
will be composed
Windows Store apps provide Windows 8 users with a unique way of interacting with their
PCs and devices. The apps are unique in their design and functionality; they share a set of
important characteristics that are fundamental in their design. To design a compelling user
experience in your app with an attractive user interface, it is important to plan your app well.
Microsoft provides Windows Store app developers with a set of guidelines to help them in
planning their app. The steps you should follow to plan and design your Windows Store app
are described in the following sections.
Decide which features will make your app great
You might have an idea to create a blog reader or a weather app. When you check the Windows Store, you might find several dozen such apps, but none of them satisfies your needs.
Although some apps may be simple to use, they are perhaps lacking in fundamental features
such as sharing data with friends. You need to determine which features you think will make
your app great and make it stand out from the rest of the apps in the Windows Store. Then,
because it’s sometimes difficult to incorporate every feature you want in the first release of
your app, prepare a list of must-have features for the first release. Your focus should be on
your users and the scenarios in which they will use your app.
Assess user scenarios
Users will interact with your app in a variety of ways and you need to anticipate as many of
them as possible. For example, in the case of a blog reader app, users might open the app if
they see an interesting post when it appears in the app’s tile. This is one scenario you need to
include when assessing the various scenarios your app will support. Then you visualize them
by using sketches, prototypes, and storyboards. Remember that your app needs to perform
well for such scenarios, and your design should accommodate any necessary requirements.
2
Chapter 1
Design Windows Store apps
www.it-ebooks.info
You might prioritize these scenarios and implement only a few of them in the first release of
your application, adding other scenarios in future updates.
Decide on your app’s features
After you decide on a set of scenarios to implement in your app, explore the Windows platform and investigate features to associate with your app’s needs. To provide users with the
best experience while using your app, follow the User Experience (UX) guidelines for each
feature.
■■
■■
■■
■■
Use the right contracts in your app Contracts are agreements between apps that
enable your app to interact with other apps. Complex interactions such as sharing
content from within your app with your friends or searching with your app are easier to
implement with contracts. If your app is a source of media, the Play To contract enables
your app to stream media to devices such as televisions.
Touch-first design Windows 8 has promoted touch and gestures as the primary
form of interaction with Windows Store apps, leaving the keyboard and mouse as
alternative methods of interaction. Therefore, you should consider using touch interactions, such as rotate, pan, swipe, cross-slide and others, to provide a more visual and
informative way to interact with content in your app.
Engaging experience Animations, toast notifications, live tiles, and secondary tiles
can help users feel deeply immersed and engaged with your app.
Use device capabilities whenever possible Modern devices have proximity sensors, cameras, accelerometers, and geolocation capabilities that you should consider
using in your app.
MORE INFO USER EXPERIENCE (UX) GUIDELINES
See for more information on UX guidelines.
Design a great user interface for your app
After you establish the features you want to implement in your app, you should start working
on the fundamentals of designing the UI. Remember that the UI is the main gateway to your
app, enabling users to be immersed and engaged with your app’s features. Microsoft design
style provides designers and developers with a set of simple principles to follow while designing the UI of Windows Store apps:
■■
Showcase your content You should strive to adapt a clean and open layout. Minimize distractions by removing unnecessary lines, boxes, blurs, and gradients; and use
open space to frame your app’s content. Remember to put “content over chrome.” You
should provide a clear and simple information hierarchy in your app with an emphasis
Objective 1.1: Design the UI layout and structure
www.it-ebooks.info
Chapter 1
3