Windows Phone 7 Development Best Practices Wiki V0.1

What is this page?

images[1].gif&sa=X&ei=xILdTP2BM8T68AaKqbjzDg&ved=0CAUQ8wc&usg=AFQjCNGArEp6lrv-4TrlLtvwf_kQ1ethAg&t=1This document represents current consensus around development best practices for Windows Phone 7.

These best practices are collaboratively developed and discussed by the WP7 developers community. As such, anyone may contribute.
This wiki page was initially edited and will continually go through quality assurance by former Microsoft Silverlight program manager Justin Angel.

Who is the target audience for this wiki?

images[4]Experienced Silverlight, WPF or WP7 Developers.

If you're new to Silverlight, never explored WP7 or a professorial designer then you're unlikely to find this wiki to be a welcoming and promising start to your WP7 career.

Rule of thumb: If you do not understand these best practices, you are most likely not the target audience for this document.

"It's ruined! It's all gone terribly terribly wrong!"

cryingbaby.jpgIf you have something valuable to add (like a super cool blog post you wrote), add it.

If you don't agree with what's on this page (like how a topic is represented), edit it.
If you think an advice is obsolete, delete it.
If you have general feedback on the wiki please open up a new discussion on the Discussion page.

Windows Phone 7 Development Best Practices Tiles


Table of contents
  1. Silverlight WP7 Custom Controls
  2. Open source frameworks or tools that explicitly support WP7
  3. Well-known WP7 sample projects
  4. Metro Design Resources
  5. Marketplace
  6. Performance
  7. Tombstoning
  8. Music And Video
  9. Photos
  10. Metro AppBar Icons
  11. Continuous Integration / Build Process
  12. Navigation
  13. Themes
  14. Globalization and Localization
  15. Trial Mode
  16. Must-read Resources
  17. Wiki Guidelines
  18. Add your section here - WP7 Accelerometers, Location Services, Push notifications, XNA, UI Controls, WP7 Emulator, Data (EF, RIA Services, OData, LINQ) or any other WP7 topic that has evolved a set of development best practices.

Silverlight WP7 Custom Controls

  1. Silverlight for Windows Phone 7 Toolkit is a freely distributed controls pack from Microsoft and supports the following controls.

    1. WP7 Toolkit October 2010 release (overview by David Anson) contains: GestureListener, ContextMenu, DatePicker, TimePicker, ToggleSwitch and WrapPanel.
    2. WP7 Toolkit November 2010 release (overview by David Anson) contains: ListPicker by David (ComboBox for WP7), AutoCompleteBox, LongListSelector and Page Transitions.

  2. Microsoft ships the official implementation of the Panorama and Pivot control with the WP7 Tools (article by Jeff Wilcox).

  3. Prior to Microsoft shipping official Panorama and Pivot control there was wide-spread use of the open source project. The official recommendation from both Microsoft and the project owner is to adopt the new Microsoft official controls. Migrate your apps sooner rather than later.

  4. Telerik ships 12 controls (8 of which are not available in the aforementioned toolkit). However, the current release is a CTP and it's unclear whether one can ship real-world projects with this license. The following controls are shipped in the current Telerik WP7 RadControls CTP:

    • WrapPanel, DockPanel, LayoutTransform, Page Transitions, UniformGrid, DatePicker, TimePicker, Window, InfiniteListBox, PickerBox.

  5. Bee Mobile currently ships 3 controls in their Bee Mobile Metropolis package and they will add more to it. These controls are currently shipped: BookControl - used to create a GUI in which the user can flip pages of a book; RegionControl - create clickable and highlightable regions of arbitrary size and shape; WaitingBar - a more common alternative to WP7 indefinite ProgressBar control.external image vs2010metropolis.png
  6. The Microsoft Silverlight Media Framework ships with support for Windows Phone 7. Including built-in a WP7 Video Player Control, Live streaming, Smooth streaming, Captions, Playlists and much more. Documentation is available here.SS-2010-11-06_21.11.15.jpg

The silverlight media framework was used (amongst other projects) in the WP7 PDC10 app.


Open source frameworks or tools that explicitly support WP7

  1. MVVM Light Toolkit is a basic and extremely popular WP7/Silverlight/WPF MVVM framework with support for Messenger, INPC and Event2Command Blend Behaviour.
  2. Caliburn.Micro is a fully-featured WP7 MVVM framework with support for Bootstrapper, Composition, Coroutines, Navigation, Tombstoning, Actions and much more. Rob Eisenberg has a "soup to nuts" blog post series explaining the basics of Caliburn.Micro.

  3. Balder - is a Silverlight 3D framework which has been ported to WP7 by Einar Ingebrigtsen.

  4. ships a nifty multi-touch library by Davide Zordan, Davide Kelly and Laurent Bugnion.

  5. Microsoft Silverlight Analytics Framework by Michael Scherotter allows reporting events back to various 3rd party analytics services.

  6. The Microsoft Advertising SDK for Windows Phone 7 introduces an AdControl that can be integrated into WP7 apps. Read the WP7 Ads Get Started guide and make sure to look over the FAQ PDF Document. One issue you should be aware of is that there are multiple reports of the AdControl increasing the application security footprint (Walt Ritscher, Brian Hitney).

  7. PreEmptive has shipped a WP7 version of Dotfuscator that supports app analytics and XAP obfuscation.
    Based on a deal between Microsoft and PreEmptive (announced by Brandon Watson) these tools will be free for WP7 developers until March 31st 2011.

  8. Eqatec has a free limited version of their Windows Phone 7 Profiler that allows profiling one assembly at a time.
  9. Jeremy Likness and Michael Washington maintain the free object-oriented database for Windows Phone 7 called Sterling.
  10. Update Controls automatically tracks dependencies and fires PropertyChanged events by generating Models from ViewModels. That has the advantage of not having to implement INotifyPropertyChanged manually in ViewModels. Notice the lack of base class in this code snippet. When either LastName or FirstName changes in the model, Update Controls fires PropertyChanged for FullName. Using this framework INPC boiler plate code is significantly reduced. PersonViewModel.jpg
  11. Add your WP7 project / tool here.

Well-known WP7 sample projects

  1. Check out patterns & practices Windows Phone 7 Developer Guide.

  2. Go over the MSDN Code Samples for Windows Phone 7. Some of these are invaluable resources when first approaching a unique WP7 API. Here's the current list of samples:
    1. Music + Videos Hub Sample
    2. Panorama/Pivot Sample
    3. Tilt Effect Sample
    4. Bing Maps Sample
    5. Globalization Sample
    6. Settings Sample
    7. Weather Forecast Sample
    8. Photos Sample
    9. Splash Screen Sample
    10. Mini-Browser Sample
    11. Application Bar Sample
    12. Location Service Sample
    13. Accelerometer Sample
    14. Hello XNA Framework Sample
    15. Reactive Extensions Location Service Emulation Sample

  3. Consider downloading the "Neurons" open source WP7 project currently shipping on the marketplace by Justin Angel.

  4. Consider downloading the "Be a Martian" open source WP7 project currently shipping on the marketplace by NASA.

  5. Add other WP7 open source sample projects here.

Metro Design Resources

  1. If you've been living in a cave and haven't read it yet, read the Windows Phone 7 UI Design and Interaction Guide for Windows Phone 7.
    If you happen to also be an iPhone developer, It's the equivalent of the iPhone HIG.

  2. Watch the Windows Phone Design Days recordings. It'll take a few hours to burn through these, but they are massively important and contain extremely important tidbits on what Metro is and how to "be" Metro. Jamie Rodriguez has a list of those sessions.

  3. Download the Expression Blend Windows Phone 7 Design Templates. , these are a Blend implementation of all those UI patterns in the aforementioned guide. Some of these are extremely helpful when first approaching an implementation of a seemingly simple WP7 Metro UI element.
  4. If you're into creating PSD mockups of your UIs, get the Photoshop WP7 Design Templates. These contain "A collection of 28 layered Photoshop template files that can be used to create pixel-perfect application layouts".

  5. When designing a WP7 application it is best to avoid manually setting properties such as Font Size, Font Family, Font Weight, Background and Foreground. Instead, use the built-in StaticResources that are part of the Theme defintion. Tore Lervik has a sample app that shows how each of these resources renders in WP7.
  6. Add more WP7 design resources here.


  1. Read the latest Windows Phone 7 Certification Guidelines. That's not a suggestion. Your apps are extremely likely to fail certification if they don't meet these requirements. These update every few months so keep an eye out for changes. If you fundementally disagree with any of these guidelines, make sure to let Microsoft know and ask for a technical exception when submitting your app. They've been very responsive in updating the guidelines and tracking exceptions.

  2. Read Michael Crump's walkthrough of the app submission process. It's extremely helpful to see how the marketplace screens look like prior to submitting an app.

  3. Microsoft publicly released a sample of their internal certification test cases, make sure you go over these.


  4. Read up on why others have failed certification. A good google search to keep handy is "Certification Test Results" "Windows Phone Marketplace" filetype:pdf.
    Here are some such results: PDF #1, PDF #2, PDF #3, Icons Bite Again for Windows Phone Marketplace by Mark Arteaga.SS-2010-11-07_16.35.55.jpg

  5. Adam Nathan who has submitted 30+ apps to the marketplace (as part of writing his "101 Windows Phone 7 apps" book) shares some vitally important tips. The WP7 marketplace online app tends to act up and not be extremely intuitive. Make sure you read this blog post before you submit apps to the marketplace.

  6. Since the marketplace currently doesn't support tracking for number of downloads you'll need to add that analytics into your app. Either use the aforementioned Microsoft Silverlight Analytics Framework or use the aforementioned PreEmptive solutions. René Schulte has a blog post that shows how to use MSAF to track unique app activations.
  7. Share any additional tips, tricks and advice related to the Windows phone marketplace here.


  1. Currently, performance on a WP7 device leaves a lot to be desired. Always test on a device, never trust the performance on the WP7 emulator.
    Never ship an app without running it on a WP7 device.

  2. When the WP7 developer tools first shipped Microsoft Silverlight Developer Jeff Wilcox tweeted invaluable performance tips for 3 straight hours. Make sure to read these advices as you won't find them anywhere else and they're quite good. Tim Heuer collected Jeff's tidbits on posted those on his blog.
  3. Kevin Marshall has a good roundup of performance best practices. Read every single line there. Percieved performance on the device is crucial for successful mobile apps.

  4. If you have a list with Images in it, it's strongly recommended to use David Anson's DeferredLoadListBox+LowProfileImageLoader or LongListSelector. They're quite easy to use and extremely effective in improving list performance on WP7.

  5. For any operation that would cause the user to wait, it's recommended to use ProgressBar.IsIndeterminate=True. However, that kills performance even more.
    You must use Jeff Wilcox's Performance ProgressBar (and remember to turn it off) for any Indeterminate ProgressBars.

  6. Watch this PDC10 session by Oren Nachman. Oren has been working for Microsoft on performance testing for top-tier WP7 apps, so he knows what he's talking about. Every tip in that presentation is priceless.
  7. Always debug WP7 applications with the default counters on. When interacting with your apps it's important to be aware of performance statistics.
    Make sure to get extremely familiar with EnableFrameRateCounter, EnableCacheVisualization and EnableRedrawRegions.
    Additionally, use Peter Torr's MemoryDiagnosticsHelper or Neudsic's MemoryMonitor to add memory counters.

  8. If your app DataBind to a ListBox that scrolls any amount of data you'll find that jittery scroll times or slow load times are quite common. Read this article by the Silverlight Performance team for a full walkthrough of your options and ways to mitigate that issue.

  9. Jaime Rodriguez (PDF) has a comprehensive cheat-sheet of WP7 performance issues and workarounds.
  10. Add any additional WP7 performance tips here.


  1. If you've ever heard of tombstoning you've seen diagrams very much like this one:

    This diagram is pretty basic and easy to grasp. However, this diagram is a massive over-simplification of what is an intricate system.
    There have been attempts by MSDN, Shawn Wildermuth and others to create better diagrams.
  2. A good example of the above diagram being overly-simplified is presented by James Ashley. The "Decactivated" event isn't just called for "Tombstoning" proper, but anytime the app goes into the background. However, applications going into the background does not equate to applications being tombstoned.

  3. Read MSDN's Execution Model Best Practices for Windows Phone.

  4. There have been a few attempts to "frameworkize" Tombstoning. It's recommanded you read up on these.
    Joost van Schaik, James Ashley, chief7 are the most well-known blog posts in this area.
  5. Kevin Marshall has a great blog post comparing different methods for serialization and what's their respective performance hit. Bottom line, if you're tombstoning anything resembling "a fair amount of data" use handcoded binary serialization. This has been confirmed by both the Facebook and Twitter WP7 apps to cause a major tombstoning performance boost.

  6. Tombstoning is only partially about maintaining "Data state", some of the state to be persisted is plain old "UI state". The most obvious example of that are selected Panorama/Pivot items and Scroll positions. Jay Kimble has an example on how to persist tombstoning state for Panorama. Jeff Fansler has an example on how to persist tombstoning state for the Pivot control.

  7. Put any other tombstoning related tip and tricks here.

Music And Video

  1. Apps can be integrated into the Music+Video hub "Marquee" by storing MediaHistoryItems of recent container (album/station) plays.
    Read MSDN's How to: Integrate with the Music and Videos Hub for Windows Phone for some fundamentals on that integration point.
    The only fully-working sample available online is from the Microsoft's official WP7 samples.

  2. Media won't play on a WP7 device when Zune is connected to the device. Gabor Dolhai blogged about a hack that allows developers to check the current network connection and if it's "Ethernet" that means WP7 is connected to Zune. If that's the case, you'll have to ask your users to disconnect WP7 from their PC.
  3. Most media types that play on a WP7 device won't play in the emulator. The emulator only plays WMV, WMA and MP3s.
    Read more about that on MSDN's Supported Media Codecs for Windows Phone.
  4. To play short sound effects use XNA's SoundEffect.FromStream(). Playing any substantial music or video using MediaElement will stop the audio playback on the user's device. The marketplace certification guidelines require that the app will continue playing the user's music after interrupting it unless it is a Music & Video hub app. Gabor Dolhai wrote a mini-framework that backups and restores currently playing Radio, Music Tracks, Music Albums and a Music Playlist.
  5. When a WP7 device is connected to Zune it will not play music or video. However, one cannot debug a WP7 device without Zune being open and connected. In the WP7 Ocotober Tools refresh Microsoft shipped the WPConnect.exe tool that allows developers to deploy and debug on WP7 devices without Zune being open. Jamie has all the details.

  6. Add your Music+Video tips and tricks here.


  1. For photo apps it's recommended to read the following 3 MSDN walkthroughs on how to best integrate with the Photos Hub:
  2. René Schulte explains how to load Photos using LoadJpeg and SaveJpeg extensions methods, iterate over all photos using MediaLibrary.Photos and add pictures to the photos hub using MediaLibrary.SavePicture.
  3. If you're using the PhotoChooserTask to choose/take a picture on WP7, you'll quickly notice that the angle the pictures are provided in aren't necessarily vertically up to down. Tim Heuer blogged about a technique to read the EXIF photo metadata, access the phone orientation and using those two parameters figure out the photo angle.

  4. Add your WP7 photos best practices here.

Metro AppBar Icons

  1. Windows Phone 7 Tools ship with the Metro AppBar default set which can be found at: Program Files\Microsoft SDKs\Windows Phone\v7.0\Icons

  2. A well-known free set of 209 additional AppBar icons is available to download here and download link here.

  3. MSDN has a must-read article on the general specifics of "Application Bar Best Practices for Windows Phone".
  4. Kirupa explains how to create a custom AppBar icon.
  5. There is a paid (10$USD) icon pack available from Billy Barker that contains 350 icons for Windows Phone 7, Android and iPhone.
  6. An extra 132 free AppBar icons extracted directly from the binary resources of the Windows Phone applications is available to download here.

  7. Add any additional information about Metro AppBar icons here.

Continuous Integration / Build Process

  1. If you're using Team Foundation Server and want to setup continuous Integration builds, read Justin Angel's blog post on setting up WP7 CI on TFS2010.
  2. Add your build or Continuous Integration WP7 best practices here.


  1. There are dual strategies to handle themes in your app. The first is supporting all possible themes combinations (Light/Dark + Accent colour). The second being to hardcode UI colours into the app and not trust StaticResources. Either way, make sure to test your app in Light Theme + Some Accent colour. Avi Pilosof shares how his app failed marketplace certification when he failed to test his app in Light Theme mode.

  2. Sometimes you'll just need to write good old fashioned "if-then-else" conditions when supporting themes. Peter Foot shared that in the WP7 RTM SDK two flags were added to let developers check if they're in Dark theme or Light theme mode.

  3. When embedding HTML in your app the WebBrowser control doesn't respect Theme properties. Ben Gracewood demos how to create HTML wrapper markup that will enforce Silverlight Theme colours in a WebBrowser control.
  4. Add your WP7 themes best practices here.


  1. The built-in WP7 navigation system has programmatic limitations when it comes to the back stack. There's no built-in method to navigate 2 pages back. To solve that, James Ashley builds a mini-framework around a technique wherein the OnNavigateTo method is handled and navigates back again as needed.
  2. Add your WP7 navigation best practices here.

Globalization and Localization

  1. The WebBrowser control will not render local characters correctly and requires those to be converted to Unicode characters. Matthias Shapiro and AEWNET have blogged about how to get the WebBrowser control to display international characters.

  2. Add your WP7 Globalization and Localization best practices here.

Trial Mode

  1. The IsTrial() method of LicenseInformation class always returns false while developing or debuging. Trial Manager by Jeff Brand has set of features to help with developing trial mode apps, such as wrapping the built-in LicenseInformation class, and adding TimeExpirationPolicy and UsageExpirationPolicy. It should however be noted that storing trial related data only on the client side is unsecure and not considered a best practice.
  2. Tom Verhoeff provides a simple howto with some additional tips & tricks on implementing trial mode in your WP7 Silverlight app. It's a good start if you need a basic introduction into trial mode.
  3. Add your Trial mode best practices here.

Must-read Resources

  • Development blogs aggregators
    • Silverlight Cream is a time-tested and well respected daily silverlight development round-up. Operated by the one and only - Dave Campbell. Subscribe to his blog/website or become obsolete next month.

    • Silverlight Show has a great roundup of Silverlight development blog posts.
  • Video Shows
    • Inside Windows Phone is a Channel9 video podcast hosted by Jamie Rodriguez and Yochay Kiriaty exclusively on WP7.

    • Silverlight TV is a Channel9 video podcast hosted by John Papa on all things Silverlight.

  • News Websites
    • WPCentral (@WPCentral) and WMPoweruser (@WMPowerUser) are both news sites with great up-to-date non-technical information on WP7.
      The best way to keep up with up to the minute reports on WP7 is to follow both of their accounts on Twitter or RSS. WPCentral tends to be more developer oriented, while WMPowerUser tends to be more "end user consumer" oriented.
  • Twitter aggregators
  • WP7 development link lists (heavily used in the making of this wiki)

  • Free ebooks
    • Consider reading Charles Petzold's "Programming Windows Phone 7" free ebook if you're interested in introduction-level samples and guidance in both Silverlight and WP7.

Wiki Guidelines

  1. 1st Rule: DO be a responsible, productive and respectful member of the WP7 developer community when contributing to this wiki.
  2. DO add links to informative blog posts detailing WP7 development best practices.
  3. DO add a short synopsis and print screens to those links.
  4. DO add links to your own blog posts. Self promotion by experts is allowed and encouraged.
  5. DO remove obsolete or misleading best practices.
  6. DO discuses disputed best practices on the WPF Disciples, AppHub WP7 forums or Silverlight.Net WP7 Forum.
  7. DON'T create original works within this wiki. If you have an original best practice, blog about it and then link back from here.
  8. DON'T dumb down the content in the wiki to fit a wider cross section of the population. This is a best practices wiki.

  1. Bee Mobile currently ships 3 controls in their Bee Mobile Metropolis package and they will add more to it. These controls are currently shipped: BookControl - used to create a GUI in which the user can flip pages of a book; RegionControl - create clickable and highlightable regions of arbitrary size and shape; WaitingBar - a more common alternative to WP7 indefinite ProgressBar control.external image vs2010metropolis.png