# [.net] Nested properties and notification

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

## 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 :
[TypeConverterAttribute(ExpandableObjectConverter::typeid)]
ref class Vector3
{
public:

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

// a few other constructors here

~Vector3(void)
{
delete m_Vector;
}

[NotifyParentPropertyAttribute(true)]
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);
}

private:

D3DXVECTOR3 *   m_Vector;

};


Now, I have something like that in another class :
public:

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 :)

1. 1
2. 2
3. 3
4. 4
Rutin
18
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631423
• Total Posts
3000003
×