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

I understand using the NETFX_CORE directive, for example:

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

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

But is there a directive specific to Windows Phone 8?

+6
source share
4 answers

Yes, the Windows Phone Directive:

 #if WINDOWS_PHONE 

This is documented here , but I am surprised that it is not mentioned. I also tested this in some code and it works.

+9
source

WP8 should use custom conditional compilation flags provided by the developer. Read more about this exact topic here . Nokia has an entire article on coding for both WP7 and WP8 , and I highly recommend that you list all the methods to see which one is the best for you.

Definition of a conditional compilation symbol:

  • Right-click the WP 8 project and select Properties. Open
  • Create a Design Project page and insert WP8 into the Conditional compilation symbols. After that they should contain something like this: SILVERLIGHT; WINDOWS_PHONE; WP8

And here is an example of inline code

 // 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 
+4
source

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

 #if !NETFX_CORE // Windows Phone 8 #endif 
+1
source

But is there a directive specific to Windows Phone 8?

You can define your own preprocessor directives that you know. WINDOWS_PHONE is simply defined by Visual Studio project templates for Windows Phone projects.

The same goes for DEBUG, TRACE and any custom ones that you may have as EXTENSIVE_LOGGING or LOOKING_FOR_A_CATBUS

0
source

All Articles