locked
Create public property on one XAML page strong typed as one Enum

    Question

  • Hi All,

     

    I have one simple XAML page with it's .CPP and .h related files, and I want to create one property strongly typed as one enum to use inside and outside this class, so it should be public, but when I compile the code I got some errors.

     

    Part of my code on the .h file is:

    "namespace MyApp

    {

          

           enum class MyEnum 

           {

                 Value 1,

                 Value 2,

                 Value 3 

           };

     

           public ref class MyPage sealed

           {

           public:

                  MyPage();

                 ~MyPage();

                

                 property MyEnum MyContext

                 {

                        MyEnum get();

                        void set (MyEnum value);

                 }

     

           private:

                 Windows::Foundation::EventRegistrationToken _displayHandlerToken;

    "

    And the error I got was:

    "Error  1      error LNK2001: unresolved external symbol "public: enum  ..."

    How can I make this enum public and use as I need? What would be the best approach?



    • Edited by Leo Soares Thursday, January 5, 2012 6:24 PM
    Tuesday, December 27, 2011 6:12 PM

Answers

  • And this is hou the Enum should be declared:

    namespace MyApplication{ 

     

    public enum class MyEnum

    {

             Value 1,

             Value 2,

             Value3

    };

    • Marked as answer by Leo Soares Thursday, January 5, 2012 6:24 PM
    Thursday, January 5, 2012 6:24 PM