Hi,
I'm trying to use NestedProperties feature with CustomTypeDescriptor and custom PropertyDescriptor, but the autogenerated PropertyDefinition does not have NestedProperties and HasNestedProperties is false:
void
AutoGeneratingPropertyDefinition(
object
sender, AutoGeneratingPropertyDefinitionEventArgs e)
{
var descriptor = e.PropertyDefinition.SourceProperty.Descriptor
as
PropertyDescriptor;
if
(descriptor !=
null
)
{
//e.PropertyDefinition.NestedProperties.Count == 0
//but descriptor.GetChildProperties().Count > 0
//why?
}
}
in my scenario:
- I set AutoGenerateProperties = true and NestedPropertiesVisibility = true;
- I have class MyCustomObject which implements ICustomTypeDescriptor (namespace System.ComponentModel)
- I have class CustomPropertyDesctriptor that inherits from PropertyDescriptor (namespace System.ComponentModel)
- ICustomTypeDescriptor.GetProperties implementation on MyCustomObject returns a collection of CustomPropertyDescriptor.
Sometimes CustomPropertyDescriptor.GetValue(object component) returns new MyCustomObject instance so I have tree hierarchy
What's the condtition I need to satisfy to autogenerate NestedProperties' PropertyDefinitions?
it is not so easy to create sample project to simulate my scenario but I can do that if you can't answer without it