Home > Store

Windows Phone 8 Unleashed

Register your product to gain access to bonus material or receive a coupon.

Windows Phone 8 Unleashed

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2013
  • Edition: 1st
  • Book
  • ISBN-10: 0-672-33689-8
  • ISBN-13: 978-0-672-33689-8

Windows® Phone 8 Unleashed is the definitive guide to Microsoft’s new Windows Phone 8 platform for intermediate to advanced developers. Written by Microsoft MVP and leading Windows Phone and WPF innovator Daniel Vaughan, this full-color guide covers everything developers need to rapidly build highly competitive Windows Phone 8 mobile apps.

Vaughan teaches through complete sample apps—leveraging the MVVM pattern—illuminating each key concept with fully explained code and real-world context. He presents best practices for building highly functional, maintainable, and attractive mobile interfaces; integrating touch, rich media, and data; testing; profiling; and more.

Expanded and updated, Vaughan shares expert insights available in no other book, drawing on his exceptional access to the Windows Phone development team through the elite Microsoft Silverlight and WPF Insiders group. Along the way, he presents exceptionally practical and thorough coverage of many powerful new Windows Phone 8 platform enhancements, including full chapters on voice commands and speech synthesis, incorporating speech-driven experiences, Wallet integration, new Live Tile capabilities, the Nokia Maps control, launching apps via file and protocol associations, and much more.

Detailed information on how to…

* Get started quickly with Windows Phone XAML development in Visual Studio

* Master the Capabilities Model, threading, and the Execution Model

* Create attractive mobile interfaces using Windows Phone’s rich set of controls, including the Windows Phone Toolkit

* Make the most of the application bar and other interface elements

* Enhance user experience with advanced support for touch, gestures, and sensors

* Build location-aware apps that use Nokia Maps and location services

* Incorporate speech-driven experiences

* Quickly internationalize apps for global markets

* Leverage Windows Phone 8’s improved camera support

* Connect apps to online services via SOAP, REST, and OData

* Validate user input on the client side or via WCF services

* Use Windows Phone 8’s powerful local database support

* Implement background actions, file transfers, and audio playback

* Automatically launch your app using file and protocol associations

* Unit test to find defects earlier, saving time and money

Downloads

Downloads

Download free code files here

Sample Content

Online Sample Chapter

Fundamental Concepts in Windows Phone Development

Sample Pages

Download the sample pages (includes Chapter 2 and Index)

Table of Contents

Preface xxii

Part I Windows Phone App Development Fundamentals

Chapter 1 Introduction to Windows Phone App Development 1

Installing the Windows Phone SDK........................................................2

Creating Your First XAML for Windows Phone App.................................2

    The Application Class..................................................................7

Summary...........................................................................................11

Chapter 2 Fundamental Concepts in Windows Phone Development 13

Understanding the Role of XAP Files....................................................14

    The Application Deployment Tool...............................................15

The Windows Phone Capabilities Model...............................................16

    Determining App Capabilities Using the Marketplace Test Kit.........17

The Threading Model for XAML-Based Graphics and Animation in Windows Phone...........................................................................18

    Performance and Element Visibility..............................................19

    Deciding Between Visibility and Opacity......................................20

Understanding the Frame Rate Counter................................................20

The Windows Phone Application Analysis Tool.....................................22

    External Events..........................................................................25

    Frame Rate Graph.......................................................................25

    CPU Usage Graph.......................................................................25

    Memory Usage MB Graph...........................................................26

    Storyboards................................................................................26

    Image Loads...............................................................................26

    GC Events..................................................................................26

    Viewing Detailed Profiling Information........................................26

Reading Device Information................................................................27

    Calculating Available Memory.....................................................28

    DeviceStatus Events...................................................................29

Applying the Model-View-ViewModel Pattern to a Windows Phone App......31

    Implementing the MVVM Pattern................................................31

    ViewModelBase Class...................................................................32

Property Change Notification..............................................................33

    Implementing INotifyPropertyChanged: The Traditional Approach.........33

    Implementing INotifyPropertyChanged: An Alternative Approach..........35

Using Commands...............................................................................38

Argument Validation..........................................................................39

A Platform-Agnostic Dialog Service.......................................................41

Consuming Local Web Applications.....................................................44

Summary...........................................................................................46

Chapter 3 Understanding the Application Execution Model 47

Exploring the Execution Model............................................................48

    Application State........................................................................49

    Life Cycle Events........................................................................49

    Programmatically Exiting an App.................................................53

    Saving Transient State.................................................................53

    Restoring Transient State.............................................................55

    Saving Persistent State.................................................................56

Implementing Fast App Resume...........................................................56

    Enabling Fast App Resume...........................................................56

    Optimizing the Resume Experience..............................................57

Running Under the Lock Screen...........................................................63

    Lock Screen Management............................................................64

Page Navigation..................................................................................67

    Navigation Using Unmapped URIs...............................................69

    Passing Page Arguments Using Query Strings................................71

    URI Mapping.............................................................................73

    Navigation Using the NavigationService.....................................75

    Handling Page Navigation...........................................................76

    Canceling Navigation.................................................................77

    Cross-Page Communication.........................................................77

    Page Redirection.........................................................................78

    Hardware Back Button................................................................79

Creating an Application Splash Screen..................................................80

Walking Through the Bookshop Sample Application.............................83

    Displaying the Product List..........................................................86

    Design-Time Data.......................................................................92

    Image Caching...........................................................................93

    Overview of the Sample Bookshop WCF Service............................95

Summary...........................................................................................97

Chapter 4 Controlling Page Orientation 99

Orientation and the PhoneApplicationPage Class..................................99

    OrientationChanged Event.........................................................100

    PhoneApplicationPage Orientation Property...............................102

    Setting Page Orientation at Runtime...........................................105

    Animating Page Elements When the Page Orientation Changes.....106

    Animating the Entire Page When Orientation Changes.................108

Windows Phone Toolkit Animated Page Transitions.............................110

    Using Windows Phone Toolkit Transitions..................................111

    Reusing the Transition Attached Properties..................................113

Summary...................................................................................114

Part II Essential Elements

Chapter 5 Using Content Controls, Items Controls, and Range Controls 115

Control Type Taxonomy....................................................................116

    Identifying Controls Not Supported or Absent in Windows Phone.........118

Content Controls...............................................................................119

    Defining the Default Content Property........................................120

Receiving Input with Buttons..............................................................121

    Tap and Click Events.................................................................123

    Button Click Mode....................................................................124

    Hyperlink Button......................................................................124

    Repeat and Toggle Buttons.........................................................124

    Radio Button.............................................................................128

    Check Box................................................................................131

    ToolTip....................................................................................138

Items Controls............................................................................138

    ListBox....................................................................................140

    ComboBox................................................................................142

Range Controls............................................................................142

    ProgressBar..............................................................................144

    Progress Indicator......................................................................145

    Slider......................................................................................151

    ScrollBar.................................................................................152

Summary....................................................................................152

Chapter 6 Mastering Text Elements and Fonts 153

Understanding Text Element Types.....................................................154

Displaying Text Using the TextBlock...................................................155

    Using the Run and LineBreak Objects..........................................155

    Multiline TextBlock Text...........................................................158

Controlling Font Properties................................................................158

Understanding the Built-In Fonts........................................................160

Using Third-Party Fonts via Font Embedding.......................................162

    Leveraging FontSource to Assign a Font Using a Stream................164

Receiving Input Using a TextBox.........................................................165

    Software Input Panel..................................................................165

    Input Scope...............................................................................168

    Input Scope Sample Overview.....................................................169

Receiving Password Text Using a PasswordBox......................................175

Displaying Rich Content Using a RichTextBox.....................................176

    Formatting Text at Runtime.......................................................178

    Further Reading.........................................................................179

Placing Text on the Clipboard............................................................179

Summary.....................................................................180

Chapter 7 Employing Media and Web Elements 183

Displaying Images with the Image Element..........................................184

    Image Sizing.............................................................................185

Providing a Drawing Surface with the InkPresenter Element................186

    Capturing User Input.................................................................188

    InkPresenter Sample Code........................................................190

Playing Audio and Video with the MediaElement..................................193

    MediaElement Sample Code........................................................194

    XNA SoundEffect Class..............................................................201

Harnessing the XNA Game Loop Via the GameTimer Class.....................202

    XNA Environment Initialization.................................................203

Saving Music to the Media Library......................................................205

Viewing High-Resolution Images with the MultiScaleImage Element.....207

    Image Tiling..............................................................................208

    Creating a Deep Zoom Image.....................................................208

    Exploring the MultiScaleImage API.............................................210

    Deep Zoom Viewer Sample Code................................................212

Displaying Web Content with the WebBrowser Element.........................217

    Monitoring and Canceling Navigation........................................217

    Communicating with a Web Page...............................................218

    Injecting Web Page Behavior......................................................222

    Storing and Browsing Content in Isolated Storage........................225

Summary.........................................................................228

Chapter 8 Taming the Application Bar 231

Exploring the Built-In Application Bar.................................................231

    Using the ApplicationBar..........................................................232

    Modifying the Application Bar’s Appearance................................234

    Icon Button and Menu Item.......................................................234

    Icon Button Image.....................................................................235

    Retrieving a Button or Menu Item at Runtime..............................236

Introducing the Custom AppBar..........................................................237

    AppBar Buttons and Menu Items.................................................237

    Button and Menu Item Visibility.................................................238

    Sample Code.............................................................................238

    Switching to Full-Screen.............................................................244

    Customizing the Appearance of the System Tray..........................247

    Inside the AppBar Control..........................................................248

Summary...........................................................................252

Chapter 9 Enriching the User Experience with the Windows Phone Toolkit Controls 253

Getting Started with the Toolkit..........................................................254

In-Place Selection Using the ListPicker..............................................255

    Display Modes...........................................................................255

Suggesting Text with the AutoCompleteBox.....................................259

    Using AutoCompleteBox with MVVM...........................................260

    Defining a Custom Filter Using the ItemFilter Property..............264

    Dynamic Population of the Suggestion List..................................266

    Styling the Suggestion List..........................................................268

    Data Binding and the AutoCompleteBox.Text Property..................270

Displaying a ContextMenu...........................................................271

    ContextMenu and MVVM............................................................273

    Hosting a ContextMenu in a ListBoxItem.....................................275

Selecting Date and Time Values with the DatePicker and TimePicker....277

    Using the DatePicker and TimePicker.........................................279

    Adding a Control Header...........................................................281

    Customizing the Value Format...................................................281

    Customizing the Full-Screen Picker Page......................................282

Providing Custom Looping Lists with the LoopingSelector...................287

Providing Touch Feedback with the TiltEffect...................................291

    Supporting Other Controls.........................................................292

Providing a Boolean Option with the ToggleSwitch..............................293

    Using the ToggleSwitch.............................................................294

    Localizing the ToggleSwitch.......................................................295

    Changing the Switch Color........................................................297

Using Flexible Layouts with the WrapPanel...........................................297

    Child Element Spacing...............................................................298

    Sample Overview.......................................................................298

    Using a WrapPanel in Conjunction with a ListBox.......................300

Summary...........................................................................302

Chapter 10 Creating Jump Lists with the Long List Selector 303

Visual Structure of the Long List Selector.............................................304

Presenting Flat Lists.....................................................................305

Presenting Grouped Lists....................................................................307

Marketplace App List Sample..............................................................307

Displaying a List of Contacts Using the LongListSelector....................316

Summary........................................................................................323

Chapter 11 Creating Expansive and Engaging Apps with the Pivot and Panorama 325

Pivot and Panorama Differences and Similarities...................................326

    Style Assumptions.....................................................................326

    Introduction to the Pivot Control..............................................327

    Introduction to the Panorama Control.........................................327

Pivot and Panorama Placement in the FCL...........................................328

Performance Improvements in Windows Phone 8.................................329

Using the Pivot Control.....................................................................329

    Placing a Pivot on a Page...........................................................329

    Creating a Pivot Application with the Visual Studio New Project Dialog..................................331

    Pivot Anatomy.........................................................................331

    Setting the Active PivotItem......................................................332

    Pivot Load Events.....................................................................333

    Hosting Multiple Application Bars with the Pivot........................333

    Populating a Pivot Via a Data Bound Collection..........................344

Using the Panorama Control........................................................347

    Panorama Anatomy....................................................................347

    PanoramaItem Control................................................................349

    Sample Panorama Application......................................................350

Things to Avoid When Using the Panorama and Pivot..........................355

Windows Phone Toolkit Lockable Pivot...............................................355

Summary.......................................................................................355

Part III Windows Phone App Development

Chapter 12 Processing Touch Input 357

Handling Touch with Mouse Events....................................................358

Touch and TouchPoint Classes.............................................................360

    Mouse Event Promotion.............................................................361

    Handling the Touch.FrameReported Event...................................362

Manipulation Events..........................................................................363

    Handling Manipulation Events...................................................364

    Manipulation Events Example....................................................366

UIElement Touch Gesture Events.........................................................368

    Tap Gesture..............................................................................369

    Double Tap Gesture...................................................................370

    Hold Gesture.............................................................................371

Windows Phone Toolkit Gestures........................................................372

    Getting Started with Toolkit Gestures..........................................373

    GestureListener Events in Detail...............................................373

    GestureBegin and GestureCompleted Events................................380

    Gesture Sample Code.................................................................381

Designing Touch-Friendly User Interfaces............................................386

    Three Components of Touch......................................................386

    Sizing and Spacing Constraints...................................................387

    General Guidelines....................................................................387

Summary..................................................................................388

Chapter 13 Portraying Your App with Live Tiles 389

Getting Started with Live Tiles............................................................389

    Tile Sizes and Resolutions...........................................................391

Introducing the Cycle Tile Template....................................................391

Introducing the Flip Tile Template......................................................394

Introducing the Iconic Tile Template...................................................395

Programmatically Updating Shell Tiles.................................................396

Controlling the Lock Screen’s Background and Notification Area...........397

    Setting the Lock Screen’s Background Image................................399

    Setting the Lock Screen’s Notification Text..................................401

    Creating a Lock Screen Icon.......................................................403

Summary........................................................................404

Chapter 14 Leveraging Built-In Apps via Launchers and Choosers 405

API Overview....................................................................................405

Choosers and the Application Execution Model....................................407

    Internal Workings of the ChooserBase.Completed Event...............407

Launchers and Choosers in Detail.......................................................408

    Retrieve Driving Directions Using the BingMapsDirectionsTask.....409

    Displaying a Location on a Map Using the BingMapsTask..............413

    Navigating to a Connection Setting Page Using the ConnectionSettingsTask..........................................................413

    Selecting an Email Address with the EmailAddressChooserTask.....414

    Preparing an Email with the EmailComposeTask............................417

    Saving a Contact’s Email Using the SaveEmailAddressTask...........418

    Navigating to an App on the Marketplace with the MarketplaceDetailTask...........................................................422

    Launching the Marketplace App with the MarketplaceHubTask......425

    Allowing the User to Review Your App Using the MarketplaceReviewTask...........................................................426

    Searching the Marketplace with the MarketplaceSearchTask.........427

    Playing a Media File Using the MediaPlayerLauncher....................428

    Placing a Call with the PhoneCallTask.........................................435

    Selecting a Phone Number with the PhoneNumberChooserTask.......437

    Saving a Contact’s Phone Number with the SavePhoneNumberTask...439

    Searching the Web with the SearchTask......................................442

    Sending Contacts a Link Using the ShareLinkTask.......................444

    Posting a Status Update to Social Networks Using the ShareStatusTask.....................................................................445

    Preparing an SMS With the SmsComposeTask................................445

    Navigating to a Web Page Using the WebBrowserTask....................446

    Selecting a Contact’s Address Using the AddressChooserTask........447

    Saving a Contact to the Phone’s Contact List Using the SaveContactTask.....................................................................449

    Taking a Photo with the CameraCaptureTask................................450

    Inviting Game Players with the GameInviteTask...........................453

    Selecting a Photo from the Photo Hub Using the PhotoChooserTask...................................................................454

    Sharing Images with Other Devices Using NFC or with Other Registered Phone Services...............................................460

    Creating a Ringtone with an Audio File Using the SaveRingtoneTask...................................................................461

Contacts and Appointments...............................................................464

    Retrieving Contacts...................................................................464

    Storing Contacts in the Custom Contact Store.............................469

    Detecting Changes in Stored Contacts.........................................477

    Converting a Stored Contact to and from a vCard........................478

    Retrieving Appointments............................................................478

Saving an Appointment Using the SaveAppointmentTask......................483

Summary......................................................................484

Chapter 15 Receiving Messages from the Cloud Using Push Notification 485

Push Notifications Types....................................................................485

Benefits of Push Notification..............................................................486

Understanding Push Notification........................................................487

Getting Started with Push Notification................................................489

Subscribing to Push Notification.........................................................489

    Binding to the Shell...................................................................490

    HttpNotificationChannel Events................................................491

    Handling Channel Errors...........................................................492

Power Management and Push Notification...........................................493

Sending Push Notifications.................................................................495

Toast Notifications.............................................................................495

    Receiving a Toast Notification from Within an Application...........496

    Sending a Toast Notification.......................................................497

Tile Notifications...............................................................................500

    Sending a Tile Notification.........................................................501

    Updating an Application Tile Using a Shell Tile Schedule..............504

Raw Notifications..............................................................................505

    Sending a Raw Notification........................................................505

    Receiving a Raw Notification......................................................508

Identifying Notifications in an HttpWebResponse..................................509

Notification Classes......................................................509

Cloud Service Authentication.............................................................511

    Authenticating a Cloud Service...................................................511

    Creating a Notification Channel for an Authenticated Cloud Service.....511

Building a Stock Ticker Application.....................................................511

    Sample App Notifications...........................................................520

Summary.......................................................................524

Chapter 16 Sensing Motion and Attitude 525

Sensors Overview....................................................525

Measuring Force with the Accelerometer..............................................527

    Using the Accelerometer Class...................................................528

    Simulating Acceleration with the Emulator..................................529

    Smoothing Accelerometer Readings.............................................530

    Calibrating the Accelerometer.....................................................533

    Shake Detection........................................................................537

Measuring Direction with the Compass...............................................539

    Using the Compass Sensor..........................................................539

    Compass Orientation.................................................................545

    Calibrating the Compass............................................................546

Sensing Rotation with the Gyroscope..................................................548

    Using the Gyroscope Sensor.......................................................549

Improving Sensor Accuracy with the Motion Sensor.............................552

    Using the Motion Sensor............................................................553

Summary...........................................................................557

Chapter 17 Building Location Aware Apps 559

Location Sensing Technologies...........................................................559

    A-GPS.......................................................................................560

    Cell Tower Triangulation............................................................561

    Wi-Fi Triangulation...................................................................562

Geographic Location Architecture.......................................................562

Getting Started with Location.............................................................563

    Geolocator Class.......................................................................563

Background Location Tracking............................................................569

Testing Apps That Use the Geolocator.................................................570

Code-Driven Location Simulation.......................................................571

A Walkthrough of the Location Viewer Sample....................................575

    GeoLocationViewModel Class.......................................................575

    Displaying Location Using the GeoLocationView Page...................577

    Civic Address Resolution............................................................580

Sampling the PositionChanged Event with Rx......................................580

    Getting Started with Rx for Windows Phone................................580

Summary..............................................................................584

Chapter 18 Incorporating Map-Based Positioning 585

Getting Started with the Map Control.................................................586

    Obtaining an ApplicationId and AuthenticationToken................587

Overview of the Sample Map View......................................................587

Adjusting for Low Light Conditions....................................................588

Changing Cartographic Modes............................................................589

Panning and Zooming the Map Control..............................................590

    Centering the Map to the Phone’s Current Location.....................590

    Setting the Viewable Area of the Map..........................................592

Adjusting Pitch and Heading..............................................................593

Location Tracking..............................................................................594

Overlaying Custom Map Content........................................................596

Calculating and Displaying a Route.....................................................598

    Calculating the Shortest Route Between Two Points......................598

    Using the Route Calculator.........................................................601

    Searching for a Route Using the View..........................................602

Modifying Page Elements Using Visual States.......................................604

    Displaying the Route and Itinerary..............................................609

Showing a Location with the Built-In Maps App...................................610

Showing Directions with the Built-In Maps App...................................611

Downloading Maps for Offline Use.....................................................612

Summary...............................................................................612

Chapter 19 Supporting Multiple Cultures and Languages 613

Terminology...................................................................613

Localizability Using Resx Files.............................................................614

    Getting Started with Resx Files....................................................615

    Working with Resx Files.............................................................615

Dynamic Localizability–Updating the UI When the Culture Changes....618

Localizing Images Using Resx Files......................................................620

The Resx Localizability Sample............................................................621

    Controlling the UI Culture from the LocalizabilityViewModel.....622

    Displaying Localized Text and Images Within the LocalizabilityView Page..........625

    RTL Support..............................................................................629

Summary...................................................................630

Chapter 20 Extending the Windows Phone Picture Viewer 631

Creating a Photos Extras Application...................................................632

    Adding Your App to the Extras Menu..........................................634

    An Edge-Tracing Extras Application.............................................634

    Saving the Image.......................................................................643

Share Menu Extensibility....................................................................645

    Adding Your App to the Share Menu...........................................646

    A Simple Photo Upload Share Application...................................647

Summary.......................................................................654

Chapter 21 Capturing Images and Video with the Camera 655

PhotoCamera...................................................................656

    Building a PhotoCamera App.......................................................658

Using the Silverlight Webcam API.......................................................678

    CaptureSourceViewModel............................................................680

    Displaying Video in the CaptureSourceView.................................684

Extending the Camera Experience with a Lens.....................................686

    Registering as a Lens..................................................................687

    Creating Lens Icons...................................................................689

Summary............................................................................689

Chapter 22 Recording Audio with the Microphone 691

Recording Audio with the Microphone................................................691

    Creating a Helium Voice App.....................................................692

Summary...................................................................698

Chapter 23 Creating Speech Driven Experiences 699

User Input with Speech Recognition....................................................700

    Getting Started with Speech Recognition.....................................700

    Overview of Recognition Grammars............................................701

    Recognizing Speech Using the Dictation and Web Search Grammars....702

    Recognizing Speech with Phrase List Grammars...........................703

    Recognizing Speech with SRGS Grammars...................................710

    Speech Recognizer Settings.........................................................717

    Providing a Custom Speech Recognition UI.................................718

    Recognizing Speech in Other Languages......................................721

Launching Your App via Voice Commands..........................................723

    Understanding the Structure of the VCD File...............................724

    Installing a VCD........................................................................726

    Updating a Phrase List Programmatically.....................................731

Making the Phone Speak with Text-to-Speech......................................732

    Getting Started with TTS............................................................732

    Creating a Speech Synthesis Markup Language File.......................733

Summary......................................................................735

Chapter 24 Unit Testing Apps 737

Automated Testing........................................................738

    Unit Testing..............................................................................738

    Integration Testing....................................................................739

    Coded UI Testing.......................................................................739

Introduction to the Windows Phone Unit Test Framework....................739

Creating a Test Project.......................................................................740

Creating a Test Class.......................................741

Tag Expressions.........................................................743

    Setting the Tag Expression Programmatically...............................744

Metadata and Assertions..................................................744

    TestClass Attribute...................................................................744

    TestMethod Attribute.................................................................745

    Metadata for Test Initialization and Cleanup................................745

    Miscellaneous Metadata.............................................................747

    WorkItemTest: The Base TestClass Type......................................751

    Verifying Conditions with Assertions..........................................751

    Verifying Collection Conditions with CollectionAssert...............752

    Verifying String Conditions with StringAssert............................752

    Hiding the Expressions Editor.....................................................752

    Testing Multiple Assemblies........................................................753

    Testing Nonpublic Members.......................................................753

A Testable Chat Client.......................................................................754

    Building the View......................................................................758

    Code Driven UI Testing..............................................................760

    Using Automation Peers to Manipulate UI Elements at Runtime....763

Inversion of Control (IoC)..................................................................765

    A Custom IoC Container and DI Framework................................766

Testing Trial Conditions.....................................................................767

    Abstracting the LicenseInformation Class...................................767

Testing with Launchers and Choosers..................................................769

Summary............................................................................771

Chapter 25 Manage Payment Instruments Using Wallet Extensibility 773

Introducing the Wallet Hub................................................................774

Required Capabilities for Wallet Integration.........................................775

Storing Payment Instruments in the Wallet..........................................775

    Overview of the Payment Instruments Sample App......................777

    Keeping Payment Instruments Up-To-Date with a Background Agent...................................................................789

Storing Membership Information in the Wallet....................................792

Storing Deals in the Wallet.................................................................796

    Keeping Deals and Membership Information Up-to-Date with a Background Agent.........................................................802

Summary......................................................................804

Part IV Building Data Driven Apps

Chapter 26 Validating User Input 805

Defining Input Validation..................................................................805

    Syntactic Validation...................................................................806

    Semantic Validation...................................................................806

Input Validation Using Property Setters...............................................806

    Validation Class........................................................................809

    Critical Exceptions.....................................................................809

    Binding Errors...........................................................................809

Defining Validation Visual States in Windows Phone............................810

    Validating a TextBox as the User Types........................................815

    Performing Group Validation.....................................................818

    Displaying Error Details.............................................................820

    Property Setter Validation Limitations.........................................823

Asynchronous and Composite Validation............................................824

    A Reusable Implementation of the NotifyDataErrorInfo Interface.................................................................................825

    Provisioning for Asynchronous or Synchronous Validation...........827

    Asynchronous Validation of All Properties...................................833

    An Example of Asynchronous Input Validation............................836

    Detecting a Change of Data Context...........................................840

    Adding INotifyDataErrorInfo Support to the ValidationSummary Control......................................................842

    Incorporating Group Validation..................................................844

Summary........................................................................847

Chapter 27 Communicating with Network Services 849

Network Service Technologies.............................................................850

Monitoring Network Connectivity......................................................850

    Connection Priorities.................................................................850

Introduction to OData.......................................................................855

Consuming OData.............................................................................855

    OData URI Structure..................................................................856

    Generating an OData Proxy........................................................858

    OData Query Options................................................................858

Using an OData Proxy........................................................................860

Building an eBay OData Consumer Application....................................862

    Creating an OData Wrapper.......................................................862

    EbaySearchViewModel Class........................................................864

    EbaySearchView Page.................................................................867

Fetching Data When the User Scrolls to the End of a List......................871

    Extending OData Entity Classes..................................................874

Simulating Real-World Conditions with the Simulation Dashboard........876

Moderating Data Usage with Data Sense..............................................877

    Using the Data Sense API...........................................................877

Summary..............................................................................879

Chapter 28 Preserving App State and Settings 881

Understanding Managed Storage.........................................................882

Working with Files and Directories......................................................883

    Introducing the .NET Isolated Storage API....................................884

    Introducing the WinPRT Windows Storage API............................887

    Measuring the Amount of Available Free Space............................888

    Application Settings...................................................................888

Abstracting IsolatedStorageSettings.................................................889

Building an Automatic State Preservation System..................................890

    Customizing ViewModel State Preservation..................................892

    Automatic State Preservation Inner Workings...............................893

    Unwinding a Property Lambda Expression...................................901

    Creating Property Accessor Delegates...........................................902

Summary........................................................................903

Chapter 29 Storing App Data in a Local Database 905

SQL Server Compact.........................................................906

Deployment of Local Databases...........................................................906

LINQ to SQL on the Phone.................................................................908

LINQ to SQL Platform Differences.......................................................909

Getting Started with Local Databases...................................................909

    Code-First Data Model Creation..................................................909

Sample Twitter Timeline Viewer..........................................................910

    Using the Column Attribute.........................................................912

    Data Context Change Tracking...................................................915

    TwitterUser Class.....................................................................915

    Multiplicity and the Association Attribute..................................917

    Twitter DataContext..................................................................918

    Database Utilities.......................................................................919

    Connection Strings....................................................................920

    Leveraging a Custom Twitter Service...........................................924

    Gathering the User’s Credentials with the Sign-In View................929

    Viewing Tweets with the Timeline View......................................932

Viewing a Local Database Schema.......................................................937

    File Explorers for Isolated Storage................................................938

    Viewing and Modifying an SQL CE Database File.........................940

Database-First Using SqlMetal.............................................................942

Deploying a Database to Isolated Storage..........................................943

Abstracting the Navigation Service......................................................946

Observing LINQ to SQL Queries with a Custom Log.............................948

Updating a Database Schema................................................951

    AddColumn.................................................................................952

    AddTable...................................................................................952

    AddIndex...................................................................................954

    AddAssociation.........................................................................955

    Schema Versioning....................................................................957

Mapping an Inheritance Hierarchy......................................................958

Concurrency.....................................................................................962

    ColumnAttribute.UpdateCheck...................................................965

Summary............................................................................966

Chapter 30 Auto-Launching with File and Protocol Associations 967

Understanding File and Protocol Associations......................................968

A Note About the Sample...................................................................968

Auto-Launching with a File Extension Association................................968

    Registering a File Association......................................................968

    Receiving a File Launch Request..................................................970

    Launching a File........................................................................973

How File and Protocol Associations Affect the User Experience..............976

Auto-Launching with a Protocol Association........................................977

    Registering for a Protocol Association..........................................977

    Receiving a Protocol Launch Request...........................................977

    Launching a Protocol URI..........................................................979

    Reserved Protocol Names............................................................981

Launching Built-In Apps.....................................................................981

Summary..............................................................................982

Chapter 31 Extending the Search Experience 983

Understanding Quick Cards................................................................983

Configuring Your App for Search Integration.......................................985

    Configuring the Application Manifest.........................................985

    Customizing Captions via the Extras.xml File..............................987

    Defining a Quick Card Target Page..............................................989

Creating a Landing Page to Display Quick Card Information.................994

App Instant Answer...........................................................................996

Summary....................................................................................996

Part V Multitasking

Chapter 32 Conducting Background Activities with Scheduled Actions 997

Background Tasks................................................................998

Scheduled Notifications......................................................................998

    Alarm Registration...................................................................1001

    Alarm Sample..........................................................................1002

    Reminder Registration..............................................................1005

    Reminder Sample....................................................................1006

Scheduled Tasks.....................................................................1010

    Background Agent Types..........................................................1011

    Using Scheduled Tasks.............................................................1015

    To-Do List Scheduled Task Sample............................................1019

    Updating Tiles Using a Scheduled Task Agent............................1035

    Scheduled Task API Limitations................................................1036

Using a Mutex to Access Common Resources Safely.............................1038

Summary..........................................................................1041

Chapter 33 Performing Background File Transfers 1043

Background Transfer Requests............................................1043

    Handling App Termination and Resubscription to Transfer Events......1048

Background File Transfer Sample Code..............................................1048

    Using URL Rerouting with a WCF Service..................................1049

    Retrieving the User’s Windows Live Anonymous ID...................1050

    TodoListViewModel..................................................................1052

    Backing Up the Local Database.................................................1052

    Restoring the Local Database....................................................1055

Summary......................................................................1058

Chapter 34 Coordinating Background Audio Playback 1059

Background Agent Recap..................................................................1059

Background Audio Overview.............................................................1060

Background Audio Player..................................................................1060

Representing Audio Files with the AudioTrack Class............................1062

Creating a Custom Audio Player Agent..............................................1063

AudioPlayerAgent Sample................................................................1064

    AudioPlayerAgent Virtual Methods...........................................1066

    Controlling Background Audio from Your Foreground App.........1070

Audio Streaming Agents...................................................................1076

    Using a MediaStreamSource to Play Back an Assembly Resource...1078

Summary........................................................................1079

Bibliography 1081

9780672336898    TOC    4/18/2013

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020