WP8 should use custom conditional compilation flags introduced by the developer. Read more about this exact topic here. Nokia has an entire article dedicated to coding for both WP7 and WP8 and I highly recommend you go over all techniques to see what's the best one for you to use.
Defining conditional compilation symbol:
- Right click on the WP 8 project and select Properties.
Open up the
- Build page of Project Designer and insert WP8 into Conditional
compilation symbols. After this, they should contain something like
this: SILVERLIGHT;WINDOWS_PHONE;WP8
And here's the inline code sample
// Separate implementations for different OS versions
#if WP8
// code using enhancements introduced in Windows Phone 8
#else
// code using Windows Phone OS 7.1 features
#endif
// A new Windows Phone 8 feature
#if WP8
// code using new Windows Phone 8 feature
#endif