Skip to content

Quick Tip: Windows Phone 7 Preprocessor Directive

  • #Code Sample
  • #Quick Tip
  • #Silverlight
  • #Windows Phone 7
  • #wp7dev
  • #XNA

If you’re sharing common code between Windows Phone 7 and other platforms in either Silverlight or XNA, then you may run into a need to fork some code based on the platform. This is normally done with a preprocessor directive, which for Windows Phone 7 is WINDOWS_PHONE.

#if WINDOWS_PHONE
 // TODO:: WP7 specific code
#endif

It took me a while to find this, so for future reference know that you can always find this in the project’s properties panel:

Latest status update

Migrated 110 posts off old Drupal site and relaunched SmartyPantsCoding.com as a Markdown-based Astro site. Also making new work public — Line Diet reboot and in-progress ChurchBells.

updated 2026-05-16 · Atlanta