Bring Your iPhone Apps and Skills to Windows Phone 7–or Build Apps for Both Mobile Platforms at Once If you’ve been developing for the competitive iPhone marketplace, this book will help you leverage your iOS skills on a fast-growing new platform: Windows Phone 7 (WP7). If you’re a .NET programmer, it will help you build advanced WP7 mobile solutions that reflect valuable lessons learned by iOS developers. If you’re a mobile development manager, it offers indispensable insights for planning cross-platform projects. Kevin Hoffman guides you through the entire WP7 Software Development Kit (SDK), showing how it resembles Apple’s iOS SDK, where it differs, and how to build production-quality WP7 apps that sell. Step by step, you’ll master each technology you’ll need, including C#, Silverlight, and XAML. Every new concept is introduced along with all the tools and background needed to apply it. Hoffman’s practical insights extend into every facet of WP7 development: building user interfaces; hardware and device services; WP7’s unique Application Tiles; Push Notifications; the Phone Execution Model, local storage, smart clients, Model-View-View Model (MVVM) design, security, social gaming, testing, debugging, deployment, and more. A pleasure to read and packed with realistic examples, this is the most useful WP7 development book you can find. · Compare Apple’s Objective-C and Microsoft’s C#: “second cousins twice removed” · Build rich, compelling user interfaces based on Silverlight, XAML, and events · Move from Apple’s Xcode to Visual Studio 2010 and from Interface Builder to Expression Blend · Leverage hardware and device services, including the accelerometer, GPS, photos, contacts, e-mail, and SMS · Create dynamic application Tiles to appear on the Start screen · “Push” raw data notifications to running apps · Understand and use the WP7 phone execution model · Efficiently store and retrieve data on WP7 phones · Build “smart clients” that sync locally stored data with web services · Manage growing app complexity through “separation of concerns” and MVVM · Successfully deploy apps to the Marketplace Table of Contents......Page 5 Who Are You and Why Should I Care?......Page 14 Why Should I Read This Book?......Page 15 What’s in This Book?......Page 16 The Origin of Objective-C......Page 22 The Origin of C#......Page 23 Core Syntax......Page 24 Method Calls and Message Passing......Page 27 Reference Counting and Object Ownership......Page 28 Garbage Collection......Page 29 Cleaning Up After Yourself—Object Finalization......Page 31 Why OOP?......Page 34 Building a Class......Page 35 Encapsulating Data......Page 36 Adding Behavior......Page 39 Inheritance......Page 41 Programming with Contracts......Page 45 Extending Other People’s Classes......Page 48 What Is Event-Driven Programming?......Page 52 Using the Delegate Pattern in Objective-C......Page 53 Using Events in C#......Page 55 Global Events and NSNotifications......Page 59 Review of the UIKit View System......Page 64 Displaying Graphics and Rendering in iOS......Page 65 Introduction to XAML and Silverlight......Page 66 The Two-Pass Mantra: Measure and Arrange......Page 68 Xcode and iOS Application Development......Page 72 Getting Started with Visual Studio 2010......Page 75 Introduction to Visual Studio 2010......Page 76 Overview of Apple’s Interface Builder......Page 82 Introduction to Expression Blend......Page 85 Blend Tutorial—Working with Visual States......Page 89 Using the Basic Controls......Page 96 Using Text Blocks......Page 97 Accepting User Input with TextBoxes......Page 99 Working with Buttons......Page 101 Accepting Other Forms of User Input......Page 104 Displaying Images......Page 106 Using a Basic List Box......Page 107 Performing Basic Animations......Page 110 Painting on Canvas......Page 113 Using the Grid Control......Page 114 Migrating from Navigation Bars......Page 118 Using the Silverlight Navigation System......Page 120 Spicing Up Navigation Events with Animation......Page 124 Using the Pivot Control......Page 128 Using a Panorama Application......Page 131 Using the Application Bar......Page 133 Review of Device Capabilities......Page 138 Using Launchers......Page 140 Using the Save Phone Number Task......Page 141 Using the Save Email Address Task......Page 142 Using the Search Task......Page 143 Launching the Media Player......Page 144 Sending a Text Message......Page 145 Using Choosers......Page 146 Using the Email Address Chooser Task......Page 147 Choosing or Capturing Photos on the Device......Page 148 Controlling Vibration......Page 149 Accessing a Radio Tuner......Page 150 Using the Accelerometer......Page 151 Using the GPS......Page 154 What Is a Tile?......Page 158 Creating Your First Tile......Page 160 Working with Tile Schedules......Page 161 Using Remote Background Images......Page 164 Review of Apple Push Notification Services (APNS)......Page 166 WP7 Push Notifications Overview......Page 168 Using Toast Notifications......Page 169 Using Raw Notifications......Page 175 Using Tile Notifications......Page 178 Multitasking on iOS 4......Page 182 Application Life Cycle Walkthrough......Page 184 Managing Application and Page State......Page 188 Core Data on the iPhone......Page 194 Reading and Writing Local Data with WP7......Page 197 Isolated Storage 101......Page 198 Building a Storage-Backed Databound Application......Page 199 Consuming RESTful Services......Page 210 Why LINQ to XML Is Your New Best Friend......Page 211 Consuming WCF Services......Page 217 16 Separating Your Concerns......Page 220 A Brief History of MVC......Page 221 Introduction to MVVM......Page 224 Working with MVVM Light for WP7......Page 225 Building a View Model......Page 226 Yes, But Will It Blend?......Page 231 Working with Commands......Page 233 Sending Messages with MVVM Light......Page 236 Look Ma, No Code-Behind!......Page 238 Using Service Providers......Page 240 The AutoMapper......Page 243 What Is Test-Driven Development?......Page 246 Red, Green, Refactor......Page 247 Mocks and Stubs......Page 248 Unit Testing iOS Applications......Page 250 Logic Testing......Page 251 Unit Testing Windows Phone 7 Applications......Page 252 Working with nUnit......Page 253 Working with the Silverlight Unit Test Framework......Page 254 Mocking and Stubbing......Page 259 Arrange, Act, Assert......Page 261 Refactor. Again.......Page 263 18 Building Connected Social Games......Page 266 Lobbies and Matchmakers......Page 267 Leaderboards and Achievements......Page 268 Turn-Based Game Play......Page 269 Achievements......Page 270 Networking API......Page 271 Lobbies and Matchmakers......Page 272 Leaderboards and Achievements......Page 274 Turn-Based Game Play......Page 276 Real-Time Multiplayer Gaming......Page 277 What Is a Secure Application?......Page 280 A Fool and His Money......Page 281 WP7 Secure by Default......Page 282 Protecting Data......Page 283 Protecting Intellectual Property......Page 288 Debugging and Tuning iOS Applications......Page 292 Debugging 101......Page 293 Using Breakpoints......Page 294 Logging and the Debug Class......Page 297 Using Static Analysis......Page 298 Introducing Zombie Apocalypse Trainer......Page 302 Registering and Deploying to Test Devices......Page 305 Prepping Your Application for Submission......Page 307 Submitting an App to the Marketplace......Page 309 Earning Money with the Mobile Advertising SDK......Page 313 A......Page 314 C......Page 315 D......Page 317 G......Page 318 I......Page 319 M......Page 320 N......Page 321 P......Page 322 S......Page 323 T......Page 324 W......Page 325 Y–Z......Page 326 Bring Your iPhone Apps and Skills to Windows Phone 7—or Build Apps for Both Mobile Platforms at Once If you've been developing for the crowded iPhone marketplace, this book will help you leverage your iOS skills on a fast-growing new platform: Windows Phone 7 (WP7). If you're a.NET programmer, it will help you build advanced WP7 mobile solutions that reflect valuable lessons learned by iPhone developers. If you're a mobile development manager, it offers indispensable insights for planning cross-platform projects. Kevin Hoffman guides you through the entire WP7 SDK, showing how it resembles Apple's iOS SDK, where it differs, and how to build production-quality WP7 apps that sell. Step by step, you'll master each technology you'll need, including C#, Silverlight and XAML. Every new concept is introduced along with all the tools and background needed to apply it. Hoffman's practical insights extend into every facet of WP7 development: building user interfaces; hardware and device services; WP7's unique Application Tiles; Push Notifications; the Phone Execution Model, local storage, smart clients, MVVM design, security, social gaming, testing, debugging, deployment, and more. A pleasure to read and packed with realistic examples, this is the most useful Windows Phone 7 development book you can find. ·¿¿¿¿¿¿¿¿ Compare Apple's Objective-C and Microsoft's C#: “second cousins twice removed” ·¿¿¿¿¿¿¿¿ Apply C# object techniques—including encapsulation, inheritance, contracts, and interfaces ·¿¿¿¿¿¿¿¿ Build rich, compelling user interfaces based on Silverlight, XAML, and events ·¿¿¿¿¿¿¿¿ Move from Apple's Xcode to Visual Studio 2010 and from Interface Builder to Expression Blend ·¿¿¿¿¿¿¿¿ Leverage hardware and device services, including the accelerometer, GPS, photos, contacts, e-mail, and SMS ·¿¿¿¿¿¿¿¿ Create dynamic application Tiles to appear on the Start screen ·¿¿¿¿¿¿¿¿ “Push” raw data notifications to running apps ·¿¿¿¿¿¿¿¿ Understand and use the Windows Phone 7 phone execution model ·¿¿¿¿¿¿¿¿ Efficiently store and retrieve data on WP7 phones ·¿¿¿¿¿¿¿¿ Build “smart clients” that sync locally stored data with web services ·¿¿¿¿¿¿¿¿ Manage growing app complexity through “separation of concerns” and MVVM (Model-View-View Model) ·¿¿¿¿¿¿¿¿ Use TDD and automated testing to accelerate and streamline development ·¿¿¿¿¿¿¿¿ Create casual, connected games and social apps ·¿¿¿¿¿¿¿¿ Secure apps without incurring unacceptable tradeoffs ·¿¿¿¿¿¿¿¿ Successfully deploy apps to the Marketplace Bring Your iPhone Apps and Skills to Windows Phone 7--or Build Apps for Both Mobile Platforms at Once If you've been developing for the crowded iPhone marketplace, this book will help you leverage your iOS skills on a fast-growing new platform: Windows Phone 7 (WP7). If you're a .NET programmer, it will help you build advanced WP7 mobile solutions that reflect valuable lessons learned by iPhone developers. If you're a mobile development manager, it offers indispensable insights for planning cross-platform projects. Kevin Hoffman guides you through the entire WP7 SDK, showing how it resembles Apple's iOS SDK, where it differs, and how to build production-quality WP7 apps that sell. Step by step, you'll master each technology you'll need, including C#, Silverlight and XAML. Every new concept is introduced along with all the tools and background needed to apply it. Hoffman's practical insights extend into every facet of WP7 development: building user interfaces; hardware and device services; WP7's unique Application Tiles; Push Notifications; the Phone Execution Model, local storage, smart clients, MVVM design, security, social gaming, testing, debugging, deployment, and more. A pleasure to read and packed with realistic examples, this is the most useful Windows Phone 7 development book you can find. Compare Apple's Objective-C and Microsoft's C#: "second cousins twice removed" Apply C# object techniques--including encapsulation, inheritance, contracts, and interfaces Build rich, compelling user interfaces based on Silverlight, XAML, and events Move from Apple's Xcode to Visual Studio 2010 and from Interface Builder to Expression Blend Leverage hardware and device services, including the accelerometer, GPS, photos, contacts, e-mail, and SMS Create dynamic application Tiles to appear on the Start screen "Push" raw data notifications to running apps Understand and use the Windows Phone 7 phone execution model Efficiently store and retrieve data on WP7 phones Build "smart clients" that sync locally stored data with web services Manage growing app complexity through "separation of concerns" and MVVM (Model-View-View Model) Use TDD and automated testing to accelerate and streamline development Create casual, connected games and social apps Secure apps without incurring unacceptable tradeoffs Successfully deploy apps to the Marketplace