locked
how to know running app type(windows phone or windows app) in common dll? RRS feed

  • Question

  • how to know running app type(windows phone app or windows app) in common class library?

    i am making Universal app with a class library. the common class library will be used in both windows phone app and windows app.

    i need to know the running app is whether windows phone app or windows app in class library in run time.

    Monday, October 13, 2014 2:22 AM

Answers

  • A trivial way to do it is set a value based on the WINDOWS_PHONE_APP build flag. Put this in App.xaml.cs:

    #if WINDOWS_PHONE_APP
            public const string Environment = "Phone";
    #else
            public const string Environment = "Windows";
    #endif

    Your code will test the value of App.Environment.

    • Edited by mSpot Inc Monday, October 13, 2014 7:02 PM
    • Marked as answer by Yang,Chenfei Monday, October 27, 2014 5:54 AM
    Monday, October 13, 2014 6:36 PM