You are previewing Pro Windows Phone 7 Development.
O'Reilly logo
Pro Windows Phone 7 Development

Book Description

The Windows Phone 7 platform provides a remarkable opportunity for Windows developers to create state-of-the-art mobile applications using their existing skills and a familiar toolset. For iOS and Android developers, this book provides the right level of content to

help developers rapidly come up to speed on Windows Phone. Pro Windows Phone 7 Development will help you unlock the potential of this platform and create dazzling, visually rich, and highly functional applications for the Windows Phone Marketplace.

For developers new to the Windows Phone platform, whether .NET, iPhone, or Android developers, this book starts by introducing you to the features and specifications of the Windows Phone series, and then leads you through the complete application development process. You'll learn how to use Microsoft technologies like Silverlight, .NET, the XNA Framework, Visual Studio, and Expression Blend effectively, how to take

advantage of the available sensors such as the location service, accelerometer, and touch, make your apps location-aware using GPS data, utilize the rich media capabilities of the Windows Phone series, and much more. Finally, you'll receive a full tutorial on how to publish and sell your application through the Windows Phone Marketplace.

Table of Contents

  1. Copyright
  2. About the Author
  3. About the Technical Reviewer
  4. Acknowledgments
  5. Introduction
    1. Who This Book Is For
    2. How This Book Is Structured
    3. Prerequisites
    4. Downloading the Code
    5. Contacting the Author
  6. 1. Introduction to Windows Phone 7 and Marketplace
    1. 1.1. Why Should I Care?
      1. 1.1.1. Smartphone Growth
      2. 1.1.2. Is Microsoft Committed?
    2. 1.2. Current Microsoft Developers
    3. 1.3. Non-Microsoft Developers
    4. 1.4. The Mobile Market
    5. 1.5. Windows Phone 7 Platform Overview
      1. 1.5.1. Phone Design Philosophy
      2. 1.5.2. Hardware Capabilities
      3. 1.5.3. Software Capabilities
    6. 1.6. Windows Phone Developer Tools
    7. 1.7. Silverlight Tools and Framework Overview
      1. 1.7.1. Silverlight for Windows Phone
      2. 1.7.2. Hello Silverlight for Windows Phone
        1. 1.7.2.1. Visual Studio 2010 Tour
        2. 1.7.2.2. Expression Blend 4 for Windows Phone Tour
    8. 1.8. XNA Game Studio and Framework Overview
      1. 1.8.1. Hello XNA for Windows Phone
        1. 1.8.1.1. Game Content
        2. 1.8.1.2. The Game Loop
          1. 1.8.1.2.1. Fixed-Step Game Loop
          2. 1.8.1.2.2. Variable-Step Game Loop
      2. 1.8.2. Implement the Game
    9. 1.9. AppHub and the Windows Marketplace for Mobile
      1. 1.9.1. Windows Phone Marketplace Registration
      2. 1.9.2. Submitting Applications to Marketplace
        1. 1.9.2.1. Making Money
        2. 1.9.2.2. Marketing Matters
      3. 1.9.3. Bing Visual Search for Windows Phone 7
      4. 1.9.4. Windows Phone Marketplace on the PC
      5. 1.9.5. Marketplace on the Device
        1. 1.9.5.1. Supported Business Models
        2. 1.9.5.2. Search, Browse, and Discover Applications
        3. 1.9.5.3. Application and Game Updates
        4. 1.9.5.4. Connecting with Your End Users
          1. 1.9.5.4.1. Stay Connected to Users via Live Tiles
          2. 1.9.5.4.2. Temp Users to Purchase with Try Before You Buy
      6. 1.9.6. Limiting Distribution of Applications
        1. 1.9.6.1. Deploy an Application to Your Phone for Testing
        2. 1.9.6.2. Limit Availability to Beta Testers
        3. 1.9.6.3. Enterprise Applications in Marketplace
    10. 1.10. Conclusion
  7. 2. Silverlight User Interface Development
    1. 2.1. Designing for Windows Phone 7
      1. 2.1.1. Design Approach
      2. 2.1.2. Design Resources
        1. 2.1.2.1. Windows Phone Design System – Codename Metro
        2. 2.1.2.2. UI Design and Interaction Guide for Windows Phone 7
        3. 2.1.2.3. Application Icons
        4. 2.1.2.4. Design Templates for Windows Phone 7
      3. 2.1.3. Designer and Developer Mechanics
    2. 2.2. User Interface Development in Visual Studio 2010
      1. 2.2.1. WMAppManifest.xml File
      2. 2.2.2. Anatomy of a WP7 Application
        1. 2.2.2.1. Configuration Settings Service
        2. 2.2.2.2. The Default App() Constructor
        3. 2.2.2.3. ApplicationUnhandledException Event
      3. 2.2.3. Anatomy of a PhoneApplicationPage
        1. 2.2.3.1. Orientation
        2. 2.2.3.2. SystemTray
        3. 2.2.3.3. Application Bar
      4. 2.2.4. Page Navigation
        1. 2.2.4.1. NavigationService
        2. 2.2.4.2. OnNavigated Overrides
    3. 2.3. .NET Framework for Silverlight
      1. 2.3.1. XAML Overview
        1. 2.3.1.1. Importing a .NET Class into XAML
        2. 2.3.1.2. Programming XAML
      2. 2.3.2. Key Silverlight UI Base Classes
        1. 2.3.2.1. Graphics Primitives
        2. 2.3.2.2. Controls
    4. 2.4. User Interface Development with Expression Blend 4
      1. 2.4.1. Layout System
        1. 2.4.1.1. Canvas
        2. 2.4.1.2. StackPanel
        3. 2.4.1.3. Grid
      2. 2.4.2. Layout Controls Sample and Blend Behaviors
        1. 2.4.2.1. Behaviors Overview
        2. 2.4.2.2. Layout Controls
          1. 2.4.2.2.1. Grid Page
          2. 2.4.2.2.2. StackPanel Page
        3. 2.4.2.3. Layout Tips
      3. 2.4.3. Data Binding
        1. 2.4.3.1. Demo Live Data
        2. 2.4.3.2. Element Data Binding
        3. 2.4.3.3. Object Data Binding
        4. 2.4.3.4. XML Data Binding
          1. 2.4.3.4.1. LINQ to XML
          2. 2.4.3.4.2. XmlReader
      4. 2.4.4. Sample Data
      5. 2.4.5. Control Styling
      6. 2.4.6. Control Templates
        1. 2.4.6.1. Edit Template Menu Item
        2. 2.4.6.2. Edit Additional Templates
        3. 2.4.6.3. ListBox Customization
          1. 2.4.6.3.1. Working with ItemTemplate
          2. 2.4.6.3.2. Custom ItemsPanel
        4. 2.4.6.4. Button Customization
          1. 2.4.6.4.1. Custom Control Template
    5. 2.5. Animation Fundamentals
      1. 2.5.1. Creating an Animation Storyboard
      2. 2.5.2. Creating Animations in Blend
      3. 2.5.3. Creating Animations in Code
    6. 2.6. Application Layout
      1. 2.6.1. Panorama
        1. 2.6.1.1. Correct Title Position
        2. 2.6.1.2. Image as Title and Themes
        3. 2.6.1.3. Dynamic Background Image
        4. 2.6.1.4. Programmatically Set the Current PanoramaItem
      2. 2.6.2. Pivot
        1. 2.6.2.1. Pivot Background Image
        2. 2.6.2.2. Pivot Title Customization
        3. 2.6.2.3. Programmatically Set the Current PivotItem
        4. 2.6.2.4. Pivot vs. Panorama
    7. 2.7. Conclusion
  8. 3. Handling Input on Windows Phone 7
    1. 3.1. The Keyboard
      1. 3.1.1. Physical Keyboard
      2. 3.1.2. Soft Input Panel (SIP) Keyboard
      3. 3.1.3. Programming with the Keyboard
        1. 3.1.3.1. InputScope
        2. 3.1.3.2. Keyboard Events
    2. 3.2. Touch Input
      1. 3.2.1. Single-Point Touch
      2. 3.2.2. Raw Touch with Mouse Events
        1. 3.2.2.1. Setting Up the Basic UI
        2. 3.2.2.2. Expand Painting Functionality
        3. 3.2.2.3. Analyzing Memory
      3. 3.2.3. Multi-Point Touch
        1. 3.2.3.1. Controls
        2. 3.2.3.2. Raw Touch with Touch.FrameReported
        3. 3.2.3.3. Multi-Touch with Raw Touch
        4. 3.2.3.4. Programming with Gestures
          1. 3.2.3.4.1. Multi-Touch with XNA Framework Libraries
          2. 3.2.3.4.2. Multi-Touch with Silverlight
        5. 3.2.3.5. Programming with Manipulation Events
    3. 3.3. Accelerometer
      1. 3.3.1.
        1. 3.3.1.1. Understanding How It Works
        2. 3.3.1.2. Programming with the Accelerometer
    4. 3.4. Location
      1. 3.4.1.
        1. 3.4.1.1. Understanding How It Works
        2. 3.4.1.2. Programming with Location
    5. 3.5. Microphone Input
    6. 3.6. Camera Input
    7. 3.7. Other Inputs
    8. 3.8. Conclusion
  9. 4. Windows Phone 7 Programming Model
    1. 4.1. Device Information
      1. 4.1.1. Identifying Unique Users
      2. 4.1.2. Device Information
      3. 4.1.3. System Environment Information
      4. 4.1.4. Network Status
      5. 4.1.5. System Tray
      6. 4.1.6. Marketplace Status and Trial Mode
    2. 4.2. Application Data Persistence
      1. 4.2.1. Basic File IO
      2. 4.2.2. Object Persistence
    3. 4.3. Tasks
      1. 4.3.1.
        1. 4.3.1.1. Debugging Launchers and Choosers
        2. 4.3.1.2. Launchers
          1. 4.3.1.2.1. EmailComposeTask
          2. 4.3.1.2.2. MarketplaceHubTask
          3. 4.3.1.2.3. MarketplaceSearchTask
          4. 4.3.1.2.4. MarketplaceDetailTask
          5. 4.3.1.2.5. MarketplaceReviewTask
          6. 4.3.1.2.6. MediaPlayerLauncher
          7. 4.3.1.2.7. PhoneCallTask
          8. 4.3.1.2.8. SearchTask
          9. 4.3.1.2.9. SMSComposeTask
          10. 4.3.1.2.10. WebBrowserTask
        3. 4.3.1.3. Choosers
          1. 4.3.1.3.1. CameraCaptureTask
          2. 4.3.1.3.2. EmailAddressChooserTask
          3. 4.3.1.3.3. PhoneNumberChooserTask
          4. 4.3.1.3.4. PhotoChooserTask
          5. 4.3.1.3.5. SaveEmailAddressTask
          6. 4.3.1.3.6. SavePhoneNumberTask
    4. 4.4. Web Browser Control
      1. 4.4.1. Basic WebBrowser Control Sample
      2. 4.4.2. WebBrowser Control Scripting Sample
    5. 4.5. Asynchronous Programming
      1. 4.5.1. Background Threads
        1. 4.5.1.1. Fire and Forget Background Processing
        2. 4.5.1.2. Supporting Progress Reporting and Cancellation
    6. 4.6. Connecting Windows Phone to Services and Feeds
      1. 4.6.1. HttpWebRequest and WebClient
      2. 4.6.2. Windows Communication Foundation Support
      3. 4.6.3. Web Services
      4. 4.6.4. REST+OData
      5. 4.6.5. Plain Old REST+JSON
    7. 4.7. Bing Maps Control
      1. 4.7.1. Licensing
      2. 4.7.2. Programmatically Add a Pin
      3. 4.7.3. Data Bind to a Collection
    8. 4.8. Application Execution Model
      1. 4.8.1. User Experience
      2. 4.8.2. Event Lifecycle
      3. 4.8.3. Managing State
      4. 4.8.4. Running Under Lock Screen
    9. 4.9. Conclusion
  10. 5. Windows Phone 7 Advanced UI Development
    1. 5.1. The Model-View-ViewModel Architecture
      1. 5.1.1. MVVM Overview
        1. 5.1.1.1. BasicMVVM - Model
        2. 5.1.1.2. BasicMVVM - ViewModel
        3. 5.1.1.3. BasicMVVM - View
      2. 5.1.2. Pick a MVVM Helper SDK
      3. 5.1.3. GalaSoft MVVM Light Toolkit
        1. 5.1.3.1. MVVM Light Sample
        2. 5.1.3.2. ViewModelLocator
        3. 5.1.3.3. MvvmLightSample – Model
        4. 5.1.3.4. MvvmLightSample – VendorsViewModel
        5. 5.1.3.5. MvvmLightSample – VendorsView
        6. 5.1.3.6. Commanding and RelayCommand
        7. 5.1.3.7. MVVM Light Messenger Class
    2. 5.2. Silverlight for Windows Phone 7 Toolkit
      1. 5.2.1. Installation and Overview
      2. 5.2.2. AutoCompleteBox Control
      3. 5.2.3. ContextMenu Control
      4. 5.2.4. DatePicker and TimePicker Controls
      5. 5.2.5. ListPicker Control
      6. 5.2.6. ToggleSwitch Control
      7. 5.2.7. WrapPanel Control
      8. 5.2.8. LongListSelector Control
        1. 5.2.8.1. LongListSelector - IsFlatList
        2. 5.2.8.2. LongListSelector via LINQ
        3. 5.2.8.3. LongListSelector via Code
    3. 5.3. Creating Transitions and Interactivity
      1. 5.3.1. Toolkit Page Transitions
        1. 5.3.1.1. Sample Project
        2. 5.3.1.2. Configuring Transitions
        3. 5.3.1.3. Transitions in Depth
        4. 5.3.1.4. Transitions and UI Elements
        5. 5.3.1.5. Custom Transitions
      2. 5.3.2. Visual State Manager
        1. 5.3.2.1. Orientation Aware
    4. 5.4. The Microsoft Advertising SDK
      1. 5.4.1. Getting Started
      2. 5.4.2. Adding the Advertising Control
        1. 5.4.2.1. AdControl in Silverlight
        2. 5.4.2.2. AdControl in the XNA Framework
    5. 5.5. Conclusion
  11. 6. Windows Phone 7 Advanced Programming Model
    1. 6.1. Advanced Data Binding
      1. 6.1.1. Syndicated Services
      2. 6.1.2. Showing Progress
      3. 6.1.3. Lazy Load Images
      4. 6.1.4. Data Bind to Anything
    2. 6.2. Encryption Services
      1. 6.2.1. Secure Sockets Layer
      2. 6.2.2. Securely Encrypting Data
    3. 6.3. Working with Images on Windows Phone 7
      1. 6.3.1. Images Classes
    4. 6.4. The Windows Phone 7 Media Library
    5. 6.5. Building a Photo Extras Application
      1. 6.5.1. Creating a Photos Extra App
        1. 6.5.1.1. Extras.xml File
        2. 6.5.1.2. Retrieving the Selected Photo
    6. 6.6. Working with Video and Audio Media
      1. 6.6.1. Supported Codecs and Containers
      2. 6.6.2. Video and Audio in the Emulator
      3. 6.6.3. Progressive Download Video
        1. 6.6.3.1. Progressive Video with MediaPlayerLauncher
        2. 6.6.3.2. Progressive Video with MediaElement
        3. 6.6.3.3. MediaStreamSource
      4. 6.6.4. Streaming Video
        1. 6.6.4.1. SmoothStreamingMediaElement
        2. 6.6.4.2. Silverlight Media Framework
      5. 6.6.5. DRM
      6. 6.6.6. Audio Support
    7. 6.7. Building a music+videos Hub Application
      1. 6.7.1. Additional Assets
      2. 6.7.2. Testing music+videos Hub Applications
      3. 6.7.3. Debugging music+videos Hub Applications
      4. 6.7.4. music+videos Hub Sample Application
        1. 6.7.4.1. Update the music+videos "New" Section
        2. 6.7.4.2. Update the music+videos "Now playing" Section
        3. 6.7.4.3. Update the music+videos "History" Section
        4. 6.7.4.4. Implement Playback from music+videos Hub
    8. 6.8. Microsoft Push Notification Services
      1. 6.8.1. Raw Push Notification Description
      2. 6.8.2. Toast Push Notification Description
      3. 6.8.3. Tile Notification
      4. 6.8.4. How Microsoft Push Notifications Work
        1. 6.8.4.1. Getting Started with Push Notifications
      5. 6.8.5. Updating Application Tile Without Push Notification Services
    9. 6.9. Localization
    10. 6.10. Conclusion
  12. 7. Building 2D Games with the XNA Framework
    1. 7.1. Xbox LIVE Gamer Services
    2. 7.2. Alien Shooter
    3. 7.3. From Demo to Game
      1. 7.3.1. Game Management
      2. 7.3.2. Screens and Menus
    4. 7.4. AlienShooter Game Structure
      1. 7.4.1. Content Project
        1. 7.4.1.1. Content Pipeline
        2. 7.4.1.2. Importing the Content
      2. 7.4.2. Text and Menus
        1. 7.4.2.1. SpriteFont
        2. 7.4.2.2. Bitmap Fonts
        3. 7.4.2.3. MenuScreen Class
    5. 7.5. AlienShooter Game Play
      1. 7.5.1. Sprite Animation
      2. 7.5.2. Game Object Class
        1. 7.5.2.1. Properties
        2. 7.5.2.2. Collision Detection
        3. 7.5.2.3. GameObject Methods
      3. 7.5.3. Enemy Class
      4. 7.5.4. Hero Ship Class
        1. 7.5.4.1. User Input
        2. 7.5.4.2. Processing Input
        3. 7.5.4.3. UserGameObject Class Core Methods
        4. 7.5.4.4. Sound Effects
      5. 7.5.5. Missile Class
      6. 7.5.6. Game Status Board Class
        1. 7.5.6.1. Keeping Score
        2. 7.5.6.2. Tracking Lives
      7. 7.5.7. Updated GameplayScreen Class
        1. 7.5.7.1. GamePlay Screen Initialization
        2. 7.5.7.2. GameplayScreen Update and Draw Methods
      8. 7.5.8. Collision Detection and Memory Management
    6. 7.6. Conclusion
  13. 8. Advanced XNA Framework Development
    1. 8.1. AlienShooter Enhancements
      1. 8.1.1. Load and Save Game State
      2. 8.1.2. Tombstone Support
      3. 8.1.3. Particle System
        1. 8.1.3.1. Modifying AlienShooter
        2. 8.1.3.2. Adding Explosions and Smoke to AlienShooter
    2. 8.2. 3D Game Development
      1. 8.2.1. 3D Game Concepts
        1. 8.2.1.1. Modeling the Real World
        2. 8.2.1.2. 3D Coordinate Systems
      2. 8.2.2. Rendering 3D Primitives
        1. 8.2.2.1. Creating 3D Primitives
        2. 8.2.2.2. From Triangles to Objects
        3. 8.2.2.3. Creating the Cube
        4. 8.2.2.4. Graphics Objects and the Effect Class
        5. 8.2.2.5. Drawing the Cube
      3. 8.2.3. The Game Class
        1. 8.2.3.1. The Camera
        2. 8.2.3.2. Rendering the Cube Scene
        3. 8.2.3.3. Adding Movement
      4. 8.2.4. Rendering 3D Models
        1. 8.2.4.1. Movable Camera
        2. 8.2.4.2. 3D Game Object Management
          1. 8.2.4.2.1. GameObject3D Class
          2. 8.2.4.2.2. SceneManager Class
        3. 8.2.4.3. XNA3DModels Game Class
    3. 8.3. Conclusion