【发布时间】:2016-07-04 11:30:23
【问题描述】:
我想通过绑定来访问类成员,但没有任何 UI 或 XAML 代码。
class Foo {
public int Value { get; set; }
}
class Bar {
public Foo foo { get; set; }
}
Bar bar = new Bar() {
foo = new Foo() {
Value = 2
}
}
Binding b = new System.Windows.Data.Binding("foo.Value");
b.Source = bar;
// Now I want a method which returns bar.foo.Value, would be like that:
int value = b.GET_VALUE(); // this method would return 2
有这样的方法吗?
【问题讨论】:
-
你读过documentation吗?
-
是的,但文档包含 XAML 或用户界面元素 (TextBlock)