此代码的代码隐藏等效项是什么?
<SomeControl SomeProperty="{Binding}"/>
(如果我想在 SomeControl 的代码隐藏中而不是在消费者的 XAML 中执行此操作。)
也就是说,如何构造一个 Binding 对象,以便直接绑定(bind)到当前对象的 DataContext,而不是绑定(bind)到某个属性?
最佳答案
由于 {Binding}
只是 {Binding Path=.}
的快捷方式,因此它应该像这样简单
SomeControl.SetBinding(SomeControl.SomeProperty, new Binding("."));
关于c# - {Binding} 的代码隐藏等效项是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10732399/