假设我有这个类:
public class Foo
{
public Bar aBar {get; private set;}
public Foo(String name)
{
aBar = new Bar()
{
Name = name
}
}
}
public class Bar
{
public String Name {get; private set;}
}
如何从 Foo 类访问属性名称?到目前为止,这就是我拥有的 XAML:
<Window.Resources>
<ObjectDataProvider x:Key="myFoo" ObjectType="{x:Type local:Foo}">
<ObjectDataProvider.ConstructorParameters>
<system:String>HelloWorld</system:String>
</ObjectDataProvider.ConstructorParameters>
</ObjectDataProvider>
</Window.Resources>
我是否必须编写一个方法,用 Foo.aBar.Name 调用,.. ??