当页面的数据上下文用于其他绑定(bind)时,如何绑定(bind)到 WPF 依赖属性? (简单问题)
最佳答案
在 XAML 中:
Something="{Binding SomethingElse, ElementName=SomeElement}"
在代码中:
BindingOperations.SetBinding(obj, SomeClass.SomethingProperty, new Binding {
Path = new PropertyPath(SomeElementType.SomethingElseProperty), /* the UI property */
Source = SomeElement /* the UI object */
});
尽管通常您会以相反的方式执行此操作,并将 UI 属性绑定(bind)到自定义依赖项属性。
关于wpf - 当页面的数据上下文用于其他绑定(bind)时,如何绑定(bind)到 WPF 依赖属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/771833/