You are previewing Windows® Phone 7 Application Development 24-Hour Trainer.
O'Reilly logo
Windows® Phone 7 Application Development 24-Hour Trainer

Book Description

This unique book-and-video package for Windows® Phone 7 Application Development 24-Hour Trainer

Ramp up your knowledge for developing apps for Windows Phone 7

Apps built for previous versions of Windows phones will not run on the new Windows Phone 7, forcing developers to quickly get up to speed on this new platform. This unique book-and-video package gets you in the game of creating exciting apps for Windows Phone 7. Concise chapters and instructor-led lessons on the video quickly update your skills for understanding the Windows Phone 7 architecture and using Microsoft's Visual Studio 2010 and Expression Blend or using the free Windows Phone Developer Tools.

  • Features a book-and-video combo that quickly gets you started on developing apps for the new Windows Phone 7 platform

  • Includes working code samples on both the tutorial video and companion Web site

  • Covers installing development tools, creating a new project, supporting multi-touch, using screen rotation and auto sizing, and more

  • Explains packing and deploying your apps as well as securing your system

  • Details the Windows Phone 7 architecture and Windows Phone navigation and UI controls

Concise chapters and a tutorial video make this a must-have package if you're determined to get started developing apps for the Windows Phone 7 platform immediately!

Table of Contents

  1. Copyright
  2. ABOUT THE AUTHOR
  3. ABOUT THE TECHNICAL EDITOR
  4. CREDITS
  5. ACKNOWLEDGMENTS
  6. INTRODUCTION
    1. WHO THIS BOOK IS FOR
    2. WHAT THIS BOOK COVERS
    3. HOW THIS BOOK IS STRUCTURED
    4. INSTRUCTIONAL VIDEOS ON DVD
    5. CONVENTIONS
    6. SUPPORTING WEBSITES AND CODE
    7. ERRATA
    8. P2P.WROX.COM
  7. I. Getting Started
    1. 1. Hello, Windows Phone 7
      1. 1.1. OVERVIEW OF WINDOWS PHONE 7
      2. 1.2. SILVERLIGHT VERSUS XNA
        1. 1.2.1. Silverlight
        2. 1.2.2. Microsoft XNA
      3. 1.3. THE WINDOWS PHONE MARKETPLACE
    2. 2. Getting and Installing the Development Tools
      1. 2.1. GETTING THE INSTALLATION FILES
        1. 2.1.1. Which Files Do You Need?
          1. 2.1.1.1. Visual Studio 2010 Express for Windows Phone
          2. 2.1.1.2. Expression Blend
          3. 2.1.1.3. Windows Phone Emulator
          4. 2.1.1.4. Silverlight 4 Tools for Visual Studio 2010
          5. 2.1.1.5. XNA Game Studio
        2. 2.1.2. System Requirements
      2. 2.2. INSTALLING THE DEVELOPER TOOLS
        1. 2.2.1. Windows Phone Developer Tools
        2. 2.2.2. Expression Blend SDK
        3. 2.2.3. Visual Studio 2010 Version Compatibility
    3. 3. Understanding Windows Phone 7 Architecture
      1. 3.1. TOOLS
        1. 3.1.1. Visual Studio 2010 Express for Windows Phone
        2. 3.1.2. Visual Studio 2010
        3. 3.1.3. Expression Blend
      2. 3.2. RUNTIME
      3. 3.3. ARCHITECTURE OVERVIEW
        1. 3.3.1. Core Components
        2. 3.3.2. Common Services
        3. 3.3.3. Silverlight
        4. 3.3.4. XNA
      4. 3.4. FEATURES SUPPORTED IN WINDOWS PHONE 7
        1. 3.4.1. Class Library Support for Windows Phone 7
          1. 3.4.1.1. Microsoft.Devices
          2. 3.4.1.2. Microsoft.Devices.Radio
          3. 3.4.1.3. Microsoft.Devices.Sensors
          4. 3.4.1.4. Microsoft.Phone
          5. 3.4.1.5. Microsoft.Phone.Controls
          6. 3.4.1.6. Microsoft.Phone.Controls.Primitives
          7. 3.4.1.7. Microsoft.Phone.Info
          8. 3.4.1.8. Microsoft.Phone.Marketplace
          9. 3.4.1.9. Microsoft.Phone.Net.NetworkInformation
          10. 3.4.1.10. Microsoft.Phone.Notification
          11. 3.4.1.11. Microsoft.Phone.Reactive
          12. 3.4.1.12. Microsoft.Phone.Shell
          13. 3.4.1.13. Microsoft.Phone.Tasks
          14. 3.4.1.14. System
          15. 3.4.1.15. System.Device.Location
          16. 3.4.1.16. System.Diagnostics
          17. 3.4.1.17. System.Windows.Automation.Peers
          18. 3.4.1.18. System.Windows.Controls
          19. 3.4.1.19. System.Windows.Media.Imaging
          20. 3.4.1.20. System.Windows.Navigation
        2. 3.4.2. Components in the Silverlight for Windows Phone Toolkit
          1. 3.4.2.1. GestureService/GestureListener
          2. 3.4.2.2. ContextMenu
          3. 3.4.2.3. DatePicker
          4. 3.4.2.4. TimePicker
          5. 3.4.2.5. ToggleSwitch
          6. 3.4.2.6. WrapPanel
        3. 3.4.3. Important Silverlight Differences
          1. 3.4.3.1. Silverlight on Windows Phone 7 vs. Windows
      5. 3.5. CLOUD SERVICES
        1. 3.5.1. Microsoft Push Notification Service
        2. 3.5.2. Microsoft Location Service
        3. 3.5.3. Web Services
        4. 3.5.4. Azure
        5. 3.5.5. Portal Services
      6. 3.6. WINDOWS PHONE MARKETPLACE
        1. 3.6.1. Registration
        2. 3.6.2. Content Management
        3. 3.6.3. Sales and Billing
        4. 3.6.4. Business Intelligence
  8. II. Let's Roll!
    1. 4. Creating a New Project
      1. 4.1. WHICH PROJECT TEMPLATE TO CHOOSE?
        1. 4.1.1. Windows Phone Application
        2. 4.1.2. Windows Phone Databound Application
        3. 4.1.3. Windows Phone Class Library
        4. 4.1.4. Windows Phone Panorama Application
        5. 4.1.5. Windows Phone Pivot Application
      2. 4.2. APPLICATION SETTINGS
      3. 4.3. GETTING ADDITIONAL TEMPLATES
      4. 4.4. ADDING A CONTROL TO THE MAIN XAML PAGE
        1. 4.4.1. Adding a Control
        2. 4.4.2. Setting Control Properties
        3. 4.4.3. Adding C# Code
          1. 4.4.3.1. Add a New Event Handler to a Control in the XAML
          2. 4.4.3.2. Adding Code to the Event Handler
      5. 4.5. TRY IT
        1. 4.5.1. Lesson Requirements
        2. 4.5.2. Step-by-Step
    2. 5. Building and Testing Your Application
      1. 5.1. BUILDING YOUR APPLICATION
        1. 5.1.1. Before You Build
        2. 5.1.2. Build the Application
      2. 5.2. DEBUGGING YOUR APPLICATION
        1. 5.2.1. Setting Breakpoints
        2. 5.2.2. Stepping through the Code
      3. 5.3. USING THE PHONE EMULATOR
        1. 5.3.1. Launching the Emulator
        2. 5.3.2. Emulator Controls
      4. 5.4. TRY IT
        1. 5.4.1. Lesson Requirements
        2. 5.4.2. Step-by-Step
    3. 6. Understanding XAML
      1. 6.1. SILVERLIGHT ARCHITECTURE
        1. 6.1.1. Project Structure
          1. 6.1.1.1. MainPage.xaml
          2. 6.1.1.2. App.xaml
          3. 6.1.1.3. Properties\AppManifest.xaml
          4. 6.1.1.4. Properties\AssemblyInfo.cs
          5. 6.1.1.5. Properties\WMAppManifest.xml
        2. 6.1.2. The XAML File
        3. 6.1.3. Understanding App.xaml
      2. 6.2. LAYOUT AND POSITIONING
        1. 6.2.1. Using the Grid Control
          1. 6.2.1.1. Setting the Width and Height of the Grid
          2. 6.2.1.2. Using the Stack Panel Control
        2. 6.2.2. Dynamically Creating XAML at Runtime
      3. 6.3. TRY IT
        1. 6.3.1. Lesson Requirements
        2. 6.3.2. Step-by-Step
  9. III. The User Interface
    1. 7. Windows Phone Navigation
      1. 7.1. WORKING WITH DATABOUND PROJECTS
        1. 7.1.1. MainPage.xaml
        2. 7.1.2. DetailsPage.xaml
        3. 7.1.3. App.xaml.cs
        4. 7.1.4. MainViewModel.cs
        5. 7.1.5. ItemViewModel.cs
        6. 7.1.6. Navigating between Pages
        7. 7.1.7. Adding Pages to Your Application
      2. 7.2. WORKING WITH PIVOT PROJECTS
        1. 7.2.1. MainPage.xaml
      3. 7.3. WORKING WITH PANORAMA PROJECTS
      4. 7.4. TRY IT
        1. 7.4.1. Lesson Requirements
        2. 7.4.2. Step-by-Step
    2. 8. Working with UI Controls
      1. 8.1. UNDERSTANDING THE CONTROL MODEL
      2. 8.2. BUILT-IN CONTROLS
        1. 8.2.1. Adding a Control
          1. 8.2.1.1. Using the Toolbox to Add Controls
          2. 8.2.1.2. Adding Controls Directly to the XAML
          3. 8.2.1.3. Adding Controls at Runtime
        2. 8.2.2. Adding Controls to the Toolbox
        3. 8.2.3. Setting a Control's Properties
          1. 8.2.3.1. Setting Properties at Runtime
          2. 8.2.3.2. Using the Properties Pane to Set Properties
          3. 8.2.3.3. Setting Properties Directly in the XAML
          4. 8.2.3.4. Setting Properties as a Static Resource
            1. 8.2.3.4.1. Storing a Static Resource at the Page Level
            2. 8.2.3.4.2. Storing a Static Resource in the App.xaml file
            3. 8.2.3.4.3. Storing a Static Resource in a Resource Dictionary
      3. 8.3. BINDING DATA TO CONTROLS
        1. 8.3.1.
          1. 8.3.1.1. OneTime Binding Mode
          2. 8.3.1.2. OneWay Binding Mode
          3. 8.3.1.3. TwoWay Binding Mode
          4. 8.3.1.4. Binding Controls in the XAML
          5. 8.3.1.5. Binding Controls Programmatically
      4. 8.4. ELEMENT-TO-ELEMENT BINDING
      5. 8.5. TRY IT
        1. 8.5.1. Lesson Requirements
        2. 8.5.2. Step-by-Step
    3. 9. Managing Screen Overlays
      1. 9.1. SOFTWARE INPUT PANEL (SIP)
        1. 9.1.1. Specifying Input Scope
        2. 9.1.2. Specifying Input Scope in XAML
        3. 9.1.3. Specifying Input Scope Programmatically
      2. 9.2. APPLICATION BAR
        1. 9.2.1.
          1. 9.2.1.1. Adding the Application Bar in the XAML
          2. 9.2.1.2. Adding the Application Bar Programmatically
      3. 9.3. TRY IT
        1. 9.3.1. Lesson Requirements
        2. 9.3.2. Step-by-Step
    4. 10. Supporting Multi-Touch
      1. 10.1. MULTI-TOUCH BEHAVIORS
        1. 10.1.1. Multi-touch Behavior Properties
        2. 10.1.2. Multi-touch on the Emulator
      2. 10.2. TRY IT
        1. 10.2.1. Lesson Requirements
        2. 10.2.2. Step-by-Step
    5. 21. Using Transforms and Animations
      1. 11.1. ANIMATIONS
        1. 11.1.1. Adding an Animation
          1. 11.1.1.1. Creating the Storyboard
          2. 11.1.1.2. Creating the Animation
          3. 11.1.1.3. Starting the Animation Using an Event
        2. 11.1.2. Start, Stop, Pause, and Resume
        3. 11.1.3. Controlling the Begin Time
        4. 11.1.4. Adding Easing to an Animation
      2. 11.2. KEY-FRAME ANIMATIONS
      3. 11.3. TRY IT
        1. 11.3.1. Lesson Requirements
        2. 11.3.2. Step-by-Step
  10. IV. Enhancing the User Experience
    1. 12. Managing User Settings
      1. 12.1. ADDING USER SETTINGS TO YOUR APPLICATION
        1. 12.1.1. Adding a Settings Class to the Setting Page
        2. 12.1.2. Creating a Settings Page
        3. 12.1.3. Using a Confirmation Button
      2. 12.2. TRY IT
        1. 12.2.1. Lesson Requirements
        2. 12.2.2. Step-by-Step
    2. 13. Using Screen Rotation and Auto Sizing
      1. 13.1. SETTING SCREEN ORIENTATION
      2. 13.2. ALLOWING AUTO-SIZING
      3. 13.3. TRY IT
        1. 13.3.1. Lesson Requirements
        2. 13.3.2. Step-by-Step
    3. 14. Using Microsoft.Phone.Tasks
      1. 14.1. LAUNCHERS
      2. 14.2. USING LAUNCHERS
        1. 14.2.1. Setting the Properties of the Launcher
        2. 14.2.2. Calling the Desired Launcher Method
      3. 14.3. CHOOSERS
        1. 14.3.1. Creating an Instance of a Chooser
        2. 14.3.2. Assigning an Event Delegate
        3. 14.3.3. Adding an Event Handler
        4. 14.3.4. Invoking the Desired Chooser Method
      4. 14.4. TRY IT
        1. 14.4.1. Lesson Requirements
        2. 14.4.2. Step-by-Step
  11. V. Network Support
    1. 15. Enabling Networking
      1. 15.1. ASMX SERVICES
        1. 15.1.1. Adding a Service Reference
        2. 15.1.2. Calling the Service
        3. 15.1.3. Accessing the Returned Data
      2. 15.2. RESTFUL SERVICES
        1. 15.2.1. Calling a REST Service
        2. 15.2.2. De-serializing the Returned Stream
      3. 15.3. WINDOWS AZURE SERVICE
      4. 15.4. MICROSOFT PUSH NOTIFICATION SERVICE
        1. 15.4.1. Subscribing to a Notification
        2. 15.4.2. Registering to Handle Notifications
        3. 15.4.3. Calling the Notification Service
      5. 15.5. TRY IT
        1. 15.5.1. Lesson Requirements
        2. 15.5.2. Hints
        3. 15.5.3. Step-by-Step
    2. 16. Using the WebBrowser Control
      1. 16.1. USING THE WEBBROWSER CONTROL
        1. 16.1.1. Detecting Connection Status
        2. 16.1.2. Loading a Web Page into Your Application
        3. 16.1.3. Sending Data between the Web Page and Your Application
          1. 16.1.3.1. Sending Data from Application to Web Page
          2. 16.1.3.2. Sending Data from Web Page to Application
      2. 16.2. TRY IT
        1. 16.2.1. Lesson Requirements
        2. 16.2.2. Step-by-Step
  12. VI. Files, Data, and Storage
    1. 17. Understanding Isolated Storage
      1. 17.1. UNDERSTANDING ISOLATED STORAGE
      2. 17.2. WORKING WITH ISOLATED STORAGE
        1. 17.2.1. Using Isolated Storage Settings
        2. 17.2.2. Working with Files and Folders
          1. 17.2.2.1. Creating Files and Folders
          2. 17.2.2.2. Writing to Files
          3. 17.2.2.3. Reading from Files
        3. 17.2.3. Handling Exceptions
      3. 17.3. TRY IT
        1. 17.3.1. Lesson Requirements
        2. 17.3.2. Step-by-Step
    2. 18. Working with Data
      1. 18.1. READING FROM AN XML FILE
        1. 18.1.1. Adding the XML File
        2. 18.1.2. Copying the XML File to Isolated Storage
        3. 18.1.3. Adding a Container Class to Hold the Data
        4. 18.1.4. Parsing the XML File
        5. 18.1.5. Binding the XML to a Listbox
      2. 18.2. TRY IT
        1. 18.2.1. Lesson Requirements
        2. 18.2.2. Step-by-Step
    3. 19. Playing Music and Videos
      1. 19.1. PLAYING VIDEOS
        1. 19.1.1. Adding and Configuring the MediaElement Control
          1. 19.1.1.1. Video Play User Controls
          2. 19.1.1.2. Audio Adjustment User Controls
          3. 19.1.1.3. Download Status Control
        2. 19.1.2. Recommended Video Encoding Settings
      2. 19.2. PLAYING SONGS
        1. 19.2.1. Playing a Song
        2. 19.2.2. Using the FM Radio
      3. 19.3. TRY IT
        1. 19.3.1. Lesson Requirements
        2. 19.3.2. Step-by-Step
  13. VII. Accessing Sensor APIs
    1. 20. Using the Accelerometer
      1. 20.1. Accessing the Accelerometer Class
        1. 20.1.1. Accessing the Accelerometer Class
        2. 20.1.2. Determining the Current State of the Sensor
        3. 20.1.3. Accessing the Device's Accelerometer Sensor
      2. 20.2. TRY IT
        1. 20.2.1. Lesson Requirements
        2. 20.2.2. Step-by-Step
    2. 21. Using GPS
      1. 21.1. GETTING DATA FROM THE LOCATION SERVICE API
        1. 21.1.1. Obtaining the Geographic Coordinates for a Location
        2. 21.1.2. Obtaining the Civic Address for a Location
      2. 21.2. BING MAPS INTEGRATION
        1. 21.2.1. Adding a Map to Your Application
        2. 21.2.2. Setting the Mode
          1. 21.2.2.1. Road Mode
          2. 21.2.2.2. Aerial Mode
          3. 21.2.2.3. AerialWithLabels
        3. 21.2.3. Setting the ZoomLevel
        4. 21.2.4. Setting the CredentialsProvider
        5. 21.2.5. Loading a Map with Current Location
      3. 21.3. TRY IT
        1. 21.3.1. Lesson Requirements
        2. 21.3.2. Step-by-Step
  14. VIII. Marketing Your Application
    1. 22. Localization
      1. 22.1. LOCALIZATION
        1. 22.1.1. Creating and Adding Resource Files
        2. 22.1.2. Enabling Localization
      2. 22.2. TRY IT
        1. 22.2.1. Lesson Requirements
        2. 22.2.2. Step-by-Step
    2. 23. Packaging and Deployment
      1. 23.1. PACKAGING AND DEPLOYMENT
        1. 23.1.1. Understanding the .xap File
        2. 23.1.2. Deploying to a Phone for Testing
      2. 23.2. SETTING UP A TRIAL VERSION
        1. 23.2.1. Allowing a Trial Version
        2. 23.2.2. Adding a "Buy Now" Option
      3. 23.3. WINDOWS PHONE MARKETPLACE
        1. 23.3.1. Overview of the Marketplace Process
        2. 23.3.2. Setting Up an Account
        3. 23.3.3. Publishing to the Marketplace
      4. 23.4. TRY IT
        1. 23.4.1. Lesson Requirements
        2. 23.4.2. Step-by-Step
    3. 24. Generating Ad Revenue
      1. 24.1. ADDING ADVERTISING TO YOUR APPLICATION
        1. 24.1.1. Create a pubCenter Account
        2. 24.1.2. Register Your Application with the adCenter
        3. 24.1.3. Create an Ad Unit
        4. 24.1.4. Download and Install the SDK
        5. 24.1.5. Add an Ad Unit to your Application
      2. 24.2. TRY IT
        1. 24.2.1. Lesson Requirements
        2. 24.2.2. Step-by-Step
  15. IX. Security and Performance
    1. 25. Security
      1. 25.1. SECURING YOUR APPLICATION
        1. 25.1.1. Using the Available Cryptographic Algorithms
          1. 25.1.1.1. AES
          2. 25.1.1.2. SHA1 and SHA256
          3. 25.1.1.3. HMAC
        2. 25.1.2. Reducing the Attack Surface by Limiting Application Capabilities
      2. 25.2. TRY IT
        1. 25.2.1. Lesson Requirements
        2. 25.2.2. Step-by-Step
    2. 26. Optimizing Performance
      1. 26.1. STARTING UP YOUR APPLICATION
        1. 26.1.1. Using a Splash Screen
        2. 26.1.2. Minimizing the Constructor
        3. 26.1.3. Breaking Up Your Application
      2. 26.2. USING THE PERFORMANCEPROGRESSBAR
      3. 26.3. MANAGING WEB SERVICE REQUESTS
      4. 26.4. HIDING CONTROLS
        1. 26.4.1. Opacity Property and Caching
        2. 26.4.2. The Visibility Property
      5. 26.5. OPTIMIZING IMAGE USE
        1. 26.5.1. Using JPG Versus PNG Images
        2. 26.5.2. Limiting Image Size
        3. 26.5.3. Images or XAML?
      6. 26.6. UNDERSTANDING THREADING
        1. 26.6.1. The UI Thread
        2. 26.6.2. The Composition Thread
        3. 26.6.3. Animations in Threads
        4. 26.6.4. Background Threads
  16. A. What's on the DVD?
    1. A.1. SYSTEM REQUIREMENTS
    2. A.2. USING THE DVD
    3. A.3. WHAT'S ON THE DVD
    4. A.4. TROUBLESHOOTING
    5. A.5. CUSTOMER CARE