Jump to content
  • Advertisement
Sign in to follow this  

[.net] Nested properties and notification

This topic is 3814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've got another question about .NET, this time regarding properties :) I'd like to create a property on top of a D3DXVECTOR3 (or any other class with public members) For the moment, I'm using something like :
ref class Vector3

        Vector3(const D3DXVECTOR3 & vector) :
            m_Vector(new D3DXVECTOR3(vector))
        { }

        // a few other constructors here

            delete m_Vector;

        property float x
            float get(void) { return(m_Vector->x); }
            void set(float value) { m_Vector->x = value; }

        // same thing for y and z properties

        virtual String ^ ToString(void) override
            return("" + m_Vector->x + ";  " + m_Vector->y + ";  " + m_Vector->z);


        D3DXVECTOR3 *   m_Vector;


Now, I have something like that in another class :

    property Vector3 ^ AVector
        Vector3 ^ get(void) { /* Do something ... */ }
        void set(Vector3 ^ value) { /* Do something ... */ }
When I set an instance of this class in a PropertyGrid, the property is correctly displayed, I can expand it to edit the members (x, y or z) But when I change one of these values, the "set" method of AVector is not called ! How should I do ? I thought that was what [NotifyParentPropertyAttribute(true)] is for ... Is it possible to make the Vector3 property call its set method when one of its member was changed ? Thx for any help :)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!