有什么方法可以将属性从子控件传播到父控件 - 所以我可以访问属性 -Parent.Property1
而不是Parent.Child.Property1
?我不能使用继承-我的父级不能扩展子类型-它继承自不同的类。
此外,我不想为从孩子到父母的每个属性添加代码,例如:
public object Property1
{
get{ return Child.Property1; }
set{ ChildProperty1 = value; }
}
也许使用反射 - 像这样的东西?
public PropertyInfo[] Properties
{
get{ return Child.GetType().GetProperties(); }
set{ Child.GetType().GetProperties().SetValue() = value.GetValue()}
}
谢谢