Lessons Learned developing a Windows Phone 7 App

Quite a few folks have been playing with the Windows Phone 7 platform, creating all kinds of crazy games, utilities, etc. for this new platform. I am no different. I simply couldn’t help myself, so once I had my new Samsung Focus in hand ( November of last year I believe ), I set out to build a game that I knew I would miss terribly after replacing my iPhone 4. This post is really less about the game however, and more about the various issues I found as I built the game and got it up on the marketplace.

I learned a ton while building this game, and ran into a number of little bumps along the way, mostly due to my inexperience with the new environment, but also due to issues with docs, limitations of APIs, etc.

Here’s a quick list of the things I ran into ( in no particular order ) that I’m hoping could save you some time when building your own WP7 apps:

  1. Learned that trying to return anything other than HttpStatusCode.Ok or NotFound results in an exception being thrown when trying to retrieve the WebResponse during an EndResponse call. I was trying to return other status codes to indicate various error conditions when chatting between the phone and my web server.
  2. I struggled a bit ( like a few folks ) trying to figure out the best way to deal with Splash screens. I found this blog post quite helpful. I also found that temporarily replacing the Content property of the rootframe with my splash screen page works like a champ. The general issue with the “Splash Screen” scenario is that you really don’t want the user to stop at the splash screen when hitting the Back button on the phone. You want the app to close. This was more of a problem than it really should be. Folks on the WP7 team are well aware.
  3. I made heavy use of MVC 3 for this game, but only in regards to leaning on FormsAuthentication for auth and URL mappings for my REST based services. Worked great! One little issue I ran into here was the fact that if you want to get the FormsAuthentication ticket cookie back to a silverlight client, you have to be sure to set the HttpOnly flag to false on the cookie on the server side! That one had me stumped for *way* too long.
  4. Be sure to make heavy use of the CacheMode for your UIElements if you are doing anything even remotely interesting. The performance impact was dramatically improved after I started using that little beauty. For general performance considerations, check out this MSDN doc page.
  5. The Reactive Framework is fantastic! You’ve simply gotta check it out if you haven’t already. Check out this post for details, but the MSDN docs are a good place to start as well. Tons of great stuff on Channel9 as well.
  6. Sometimes I would hit a problem when trying to deploy my app to my USB connected phone. Follow all the common steps to correct this problem, but sometimes I found I just needed to restart my phone.
  7. Make sure to use the “High-Performance  ProgressBar for Windows Phone”. Check out this post for details.
  8. If removing or adding lots of listbox items at once, be sure to call UpdateLayout() in order for the ScrollIntoView method to work.
  9. Test your app on your phone! Don’t just lean on the simulator! Also, be sure to test your app in the light theme. I tried to be diligent about that but it still bit me during the certification process.
  10. If you use the ChildWindow class for dialogs in the SilverLight Toolkit ( which I highly recommend by the way ), be sure to handle the OnBackKey event. The requirement in order to be admitted into the marketplace is that if the user hits the back button on the phone, that should cancel any dialog and leave the user on the page the dialog was presented over. I dropped the ball on that as well.
  11. Last but not least, if you are going to have a trial version of your app, be sure to test it and make sure your logic is sound! Nothing more annoying than downloading an app expecting to trial it only to find out that the trial has already expired! Yeah, I did that. Embarrassed smile

I’m sure I’ve forgotten a few other things that tripped me up along the way, but that feels pretty comprehensive to me.

All and all, a lot of fun building this thing. The WP7 team really did a great job, and the silverlight team did a bang-up job on the developer tooling!

Hope that helps!


P.S. If you’re interested, the game my wife and I built is called “WordMe”. Pull it down, and challenge me in a word game. Bring it!

P.S.S. Oh, and I should dedicate this game to Karen Noble, who first introduced me to “that damn game” on the iPhone. Damn you Karen! Smile