Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If NETFX_CORE is for Windows 8, what is for Windows Phone 8?

I understand using the NETFX_CORE directive, like this:

#if NETFX_CORE 
    // Windows 8
#else 
    // Windows Phone 8
#endif

More info: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj714084(v=vs.105).aspx

But is there a directive specific to Windows Phone 8?

like image 794
Jerry Nixon Avatar asked Nov 27 '12 22:11

Jerry Nixon


3 Answers

Yes, the Windows Phone directive is:

#if WINDOWS_PHONE

This is documented here, but I'm surprised that it isn't mentioned here. I also tested this in some code, and it works.

like image 198
Jennifer Marsman - MSFT Avatar answered Nov 18 '22 08:11

Jennifer Marsman - MSFT


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:

  1. Right click on the WP 8 project and select Properties. Open up the
  2. 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 
like image 34
JustinAngel Avatar answered Nov 18 '22 09:11

JustinAngel


As far I know, there is not such directive. But you can use if not :

#if !NETFX_CORE 
    // Windows Phone 8
#endif
like image 1
Antonio Bakula Avatar answered Nov 18 '22 10:11

Antonio Bakula