Part I Windows Phone App Development Fundamentals
1 Introduction to Windows Phone App Development
Installing the Windows Phone SDK
Creating Your First XAML for Windows Phone App
2 Fundamental Concepts in Windows Phone Development
Understanding the Role of XAP Files
The Application Deployment Tool
The Windows Phone Capabilities Model
Determining App Capabilities Using the Marketplace Test Kit
The Threading Model for XAML-Based Graphics and Animation in Windows Phone
Performance and Element Visibility
Deciding Between Visibility and Opacity
Understanding the Frame Rate Counter
The Windows Phone Application Analysis Tool
Viewing Detailed Profiling Information
Applying the Model-View-ViewModel Pattern to a Windows Phone App
Implementing INotifyPropertyChanged
: The Traditional Approach
Implementing INotifyPropertyChanged
: An Alternative Approach
A Platform-Agnostic Dialog Service
Consuming Local Web Applications
3 Understanding the Application Execution Model
Programmatically Exiting an App
Optimizing the Resume Experience
Navigation Using Unmapped URIs
Passing Page Arguments Using Query Strings
Navigation Using the NavigationService
Creating an Application Splash Screen
Walking Through the Bookshop Sample Application
Overview of the Sample Bookshop WCF Service
4 Controlling Page Orientation
Orientation and the PhoneApplicationPage
Class
PhoneApplicationPage Orientation
Property
Setting Page Orientation at Runtime
Animating Page Elements When the Page Orientation Changes
Animating the Entire Page When Orientation Changes
Windows Phone Toolkit Animated Page Transitions
Using Windows Phone Toolkit Transitions
Reusing the Transition Attached Properties
5 Using Content Controls, Items Controls, and Range Controls
Identifying Controls Not Supported or Absent in Windows Phone
Defining the Default Content Property
6 Mastering Text Elements and Fonts
Understanding Text Element Types
Displaying Text Using the TextBlock
Using the Run
and LineBreak
Objects
Understanding the Built-In Fonts
Using Third-Party Fonts via Font Embedding
Leveraging FontSource
to Assign a Font Using a Stream
Receiving Input Using a TextBox
Receiving Password Text Using a PasswordBox
Displaying Rich Content Using a RichTextBox
7 Employing Media and Web Elements
Displaying Images with the Image
Element
Providing a Drawing Surface with the InkPresenter
Element
Playing Audio and Video with the MediaElement
Harnessing the XNA Game Loop Via the GameTimer
Class
XNA Environment Initialization
Saving Music to the Media Library
Viewing High-Resolution Images with the MultiScaleImage
Element
Exploring the MultiScaleImage
API
Displaying Web Content with the WebBrowser
Element
Monitoring and Canceling Navigation
Storing and Browsing Content in Isolated Storage
Exploring the Built-In Application Bar
Modifying the Application Bar’s Appearance
Retrieving a Button or Menu Item at Runtime
Button and Menu Item Visibility
Customizing the Appearance of the System Tray
9 Enriching the User Experience with the Windows Phone Toolkit Controls
Getting Started with the Toolkit
In-Place Selection Using the ListPicker
Suggesting Text with the AutoCompleteBox
Using AutoCompleteBox
with MVVM
Defining a Custom Filter Using the ItemFilter
Property
Dynamic Population of the Suggestion List
Data Binding and the AutoCompleteBox.Text
Property
Hosting a ContextMenu
in a ListBoxItem
Selecting Date and Time Values with the DatePicker
and TimePicker
Using the DatePicker
and TimePicker
Customizing the Full-Screen Picker Page
Providing Custom Looping Lists with the LoopingSelector
Providing Touch Feedback with the TiltEffect
Providing a Boolean Option with the ToggleSwitch
Using Flexible Layouts with the WrapPanel
Using a WrapPanel
in Conjunction with a ListBox
10 Creating Jump Lists with the Long List Selector
Visual Structure of the Long List Selector
Displaying a List of Contacts Using the LongListSelector
11 Creating Expansive and Engaging Apps with the Pivot and Panorama
Pivot
and Panorama
Differences and Similarities
Introduction to the Pivot
Control
Introduction to the Panorama
Control
Pivot
and Panorama
Placement in the FCL
Performance Improvements in Windows Phone 8
Creating a Pivot Application with the Visual Studio New Project Dialog
Hosting Multiple Application Bars with the Pivot
Populating a Pivot
Via a Data Bound Collection
Things to Avoid When Using the Panorama
and Pivot
Windows Phone Toolkit Lockable Pivot
Part III Windows Phone App Development
Handling Touch with Mouse Events
Handling the Touch.FrameReported
Event
UIElement
Touch Gesture Events
Windows Phone Toolkit Gestures
Getting Started with Toolkit Gestures
GestureListener
Events in Detail
GestureBegin
and GestureCompleted
Events
Designing Touch-Friendly User Interfaces
Sizing and Spacing Constraints
13 Portraying Your App with Live Tiles
Getting Started with Live Tiles
Introducing the Cycle Tile Template
Introducing the Flip Tile Template
Introducing the Iconic Tile Template
Programmatically Updating Shell Tiles
Controlling the Lock Screen’s Background and Notification Area
Setting the Lock Screen’s Background Image
Setting the Lock Screen’s Notification Text
14 Leveraging Built-In Apps via Launchers and Choosers
Choosers and the Application Execution Model
Internal Workings of the ChooserBase.Completed
Event
Launchers and Choosers in Detail
Retrieve Driving Directions Using the BingMapsDirectionsTask
Displaying a Location on a Map Using the BingMapsTask
Navigating to a Connection Setting Page Using the ConnectionSettingsTask
Selecting an Email Address with the EmailAddressChooserTask
Preparing an Email with the EmailComposeTask
Saving a Contact’s Email Using the SaveEmailAddressTask
Navigating to an App on the Marketplace with the MarketplaceDetailTask
Launching the Marketplace App with the MarketplaceHubTask
Allowing the User to Review Your App Using the MarketplaceReviewTask
Searching the Marketplace with the MarketplaceSearchTask
Playing a Media File Using the MediaPlayerLauncher
Placing a Call with the PhoneCallTask
Selecting a Phone Number with the PhoneNumberChooserTask
Saving a Contact’s Phone Number with the SavePhoneNumberTask
Searching the Web with the SearchTask
Sending Contacts a Link Using the ShareLinkTask
Posting a Status Update to Social Networks Using the ShareStatusTask
Preparing an SMS With the SmsComposeTask
Navigating to a Web Page Using the WebBrowserTask
Selecting a Contact’s Address Using the AddressChooserTask
Saving a Contact to the Phone’s Contact List Using the SaveContactTask
Taking a Photo with the CameraCaptureTask
Inviting Game Players with the GameInviteTask
Selecting a Photo from the Photo Hub Using the PhotoChooserTask
Sharing Images with Other Devices Using NFC or with Other Registered Phone Services
Creating a Ringtone with an Audio File Using the SaveRingtoneTask
Storing Contacts in the Custom Contact Store
Detecting Changes in Stored Contacts
Converting a Stored Contact to and from a vCard
Saving an Appointment Using the SaveAppointmentTask
15 Receiving Messages from the Cloud Using Push Notification
Understanding Push Notification
Getting Started with Push Notification
Subscribing to Push Notification
HttpNotificationChannel
Events
Power Management and Push Notification
Receiving a Toast Notification from Within an Application
Updating an Application Tile Using a Shell Tile Schedule
Identifying Notifications in an HttpWebResponse
Authenticating a Cloud Service
Creating a Notification Channel for an Authenticated Cloud Service
Building a Stock Ticker Application
16 Sensing Motion and Attitude
Measuring Force with the Accelerometer
Simulating Acceleration with the Emulator
Smoothing Accelerometer Readings
Measuring Direction with the Compass
Sensing Rotation with the Gyroscope
Improving Sensor Accuracy with the Motion Sensor
17 Building Location Aware Apps
Geographic Location Architecture
Testing Apps That Use the Geolocator
Code-Driven Location Simulation
A Walkthrough of the Location Viewer Sample
Displaying Location Using the GeoLocationView
Page
Sampling the PositionChanged
Event with Rx
Getting Started with Rx for Windows Phone
18 Incorporating Map-Based Positioning
Getting Started with the Map Control
Obtaining an ApplicationId
and AuthenticationToken
Overview of the Sample Map View
Adjusting for Low Light Conditions
Panning and Zooming the Map Control
Centering the Map to the Phone’s Current Location
Setting the Viewable Area of the Map
Calculating and Displaying a Route
Calculating the Shortest Route Between Two Points
Searching for a Route Using the View
Modifying Page Elements Using Visual States
Displaying the Route and Itinerary
Showing a Location with the Built-In Maps App
Showing Directions with the Built-In Maps App
Downloading Maps for Offline Use
19 Supporting Multiple Cultures and Languages
Localizability Using Resx Files
Getting Started with Resx Files
Dynamic Localizability—Updating the UI When the Culture Changes
Localizing Images Using Resx Files
The Resx Localizability Sample
Controlling the UI Culture from the LocalizabilityViewModel
Displaying Localized Text and Images Within the LocalizabilityView
Page
20 Extending the Windows Phone Picture Viewer
Creating a Photos Extras Application
Adding Your App to the Extras Menu
An Edge-Tracing Extras Application
Adding Your App to the Share Menu
A Simple Photo Upload Share Application
21 Capturing Images and Video with the Camera
Using the Silverlight Webcam API
Displaying Video in the CaptureSourceView
Extending the Camera Experience with a Lens
22 Recording Audio with the Microphone
Recording Audio with the Microphone
23 Creating Speech Driven Experiences
User Input with Speech Recognition
Getting Started with Speech Recognition
Overview of Recognition Grammars
Recognizing Speech Using the Dictation and Web Search Grammars
Recognizing Speech with Phrase List Grammars
Recognizing Speech with SRGS Grammars
Providing a Custom Speech Recognition UI
Recognizing Speech in Other Languages
Launching Your App via Voice Commands
Understanding the Structure of the VCD File
Updating a Phrase List Programmatically
Making the Phone Speak with Text-to-Speech
Creating a Speech Synthesis Markup Language File
Introduction to the Windows Phone Unit Test Framework
Setting the Tag Expression Programmatically
Metadata for Test Initialization and Cleanup
WorkItemTest
: The Base TestClass
Type
Verifying Conditions with Assertions
Verifying Collection Conditions with CollectionAssert
Verifying String Conditions with StringAssert
Using Automation Peers to Manipulate UI Elements at Runtime
A Custom IoC Container and DI Framework
Abstracting the LicenseInformation
Class
Testing with Launchers and Choosers
25 Manage Payment Instruments Using Wallet Extensibility
Required Capabilities for Wallet Integration
Storing Payment Instruments in the Wallet
Overview of the Payment Instruments Sample App
Keeping Payment Instruments Up-To-Date with a Background Agent
Storing Membership Information in the Wallet
Keeping Deals and Membership Information Up-to-Date with a Background Agent
Part IV Building Data Driven Apps
Input Validation Using Property Setters
Defining Validation Visual States in Windows Phone
Validating a TextBox
as the User Types
Property Setter Validation Limitations
Asynchronous and Composite Validation
A Reusable Implementation of the NotifyDataErrorInfo
Interface
Provisioning for Asynchronous or Synchronous Validation
Asynchronous Validation of All Properties
An Example of Asynchronous Input Validation
Detecting a Change of Data Context
Adding INotifyDataErrorInfo
Support to the ValidationSummary
Control
Incorporating Group Validation
27 Communicating with Network Services
Monitoring Network Connectivity
Building an eBay OData Consumer Application
Fetching Data When the User Scrolls to the End of a List
Extending OData Entity Classes
Simulating Real-World Conditions with the Simulation Dashboard
Moderating Data Usage with Data Sense
28 Preserving App State and Settings
Working with Files and Directories
Introducing the .NET Isolated Storage API
Introducing the WinPRT Windows Storage API
Measuring the Amount of Available Free Space
Abstracting IsolatedStorageSettings
Building an Automatic State Preservation System
Customizing ViewModel State Preservation
Automatic State Preservation Inner Workings
Unwinding a Property Lambda Expression
Creating Property Accessor Delegates
29 Storing App Data in a Local Database
LINQ to SQL Platform Differences
Getting Started with Local Databases
Code-First Data Model Creation
Sample Twitter Timeline Viewer
Multiplicity and the Association
Attribute
Leveraging a Custom Twitter Service
Gathering the User’s Credentials with the Sign-In View
Viewing Tweets with the Timeline View
Viewing a Local Database Schema
File Explorers for Isolated Storage
Viewing and Modifying an SQL CE Database File
Deploying a Database to Isolated Storage
Abstracting the Navigation Service
Observing LINQ to SQL Queries with a Custom Log
Mapping an Inheritance Hierarchy
30 Auto-Launching with File and Protocol Associations
Understanding File and Protocol Associations
Auto-Launching with a File Extension Association
Registering a File Association
Receiving a File Launch Request
How File and Protocol Associations Affect the User Experience
Auto-Launching with a Protocol Association
Registering for a Protocol Association
Receiving a Protocol Launch Request
31 Extending the Search Experience
Configuring Your App for Search Integration
Configuring the Application Manifest
Customizing Captions via the Extras.xml File
Defining a Quick Card Target Page
Creating a Landing Page to Display Quick Card Information
32 Conducting Background Activities with Scheduled Actions
To-Do List Scheduled Task Sample
Updating Tiles Using a Scheduled Task Agent
Scheduled Task API Limitations
Using a Mutex
to Access Common Resources Safely
33 Performing Background File Transfers
Handling App Termination and Resubscription to Transfer Events
Background File Transfer Sample Code
Using URL Rerouting with a WCF Service
Retrieving the User’s Windows Live Anonymous ID
34 Coordinating Background Audio Playback
Representing Audio Files with the AudioTrack
Class
Creating a Custom Audio Player Agent
AudioPlayerAgent
Virtual Methods
Controlling Background Audio from Your Foreground App
3.143.5.201