我正在试验ICustomTypeDescriptor接口和PropertyDescriptor类,以便在对象上创建动态属性.我在简单对象方面取得了很大成功,但我无法获得嵌套对象来创建动态属性?
例如,在下面的数据绑定对话框中,我将我的Person类添加为a StaticResource,然后尝试将数据绑定Person.Child.Name到测试框:

因为Person.Child我希望看到我动态创建的属性(Name和Age),但你可以看到它没有按预期工作?这是几乎一样,如果数据绑定对话框没有询问ICustomTypeDescriptor的接口Person.Child?
有关如何使这些嵌套属性"可见"的任何指导?
外课
public class Person : ICustomTypeDescriptor, INotifyPropertyChanged
{
private readonly List<CustomPropertyDescriptor> propertyDescriptors = new List<CustomPropertyDescriptor>();
private readonly Dictionary<string, object> properties = new Dictionary<string, object>();
public Person()
{
// 'Dynamic' Property
string name = "Name";
object value = "Person's Name";
this.properties.Add(name, value);
var propertyDescriptor = new CustomPropertyDescriptor(
typeof(Person),
name,
value,
value.GetType().GetCustomAttributes(true).Cast<Attribute>().ToArray());
this.propertyDescriptors.Add(propertyDescriptor);
// 'Dynamic' Property
name = "Child";
value …Run Code Online (Sandbox Code Playgroud)