C# 什么';是{Binding}的等价代码吗?
这个代码背后的代码是什么C# 什么';是{Binding}的等价代码吗?,c#,silverlight,silverlight-3.0,C#,Silverlight,Silverlight 3.0,这个代码背后的代码是什么 <SomeControl SomeProperty="{Binding}"/> (如果我想在SomeControl的代码隐藏中而不是在使用者的XAML中执行此操作。) 也就是说,如何构造绑定对象,以便直接绑定到当前对象的DataContext,而不是某个属性?既然{Binding}只是{Binding Path=.}的一个快捷方式,它应该与 SomeControl.SetBinding(SomeControl.SomeProperty, new Bin
<SomeControl SomeProperty="{Binding}"/>
(如果我想在SomeControl的代码隐藏中而不是在使用者的XAML中执行此操作。)
也就是说,如何构造绑定对象,以便直接绑定到当前对象的DataContext,而不是某个属性?既然
{Binding}
只是{Binding Path=.}
的一个快捷方式,它应该与
SomeControl.SetBinding(SomeControl.SomeProperty, new Binding("."));
看看:
可能的副本不完全相同。我知道怎么做。我不知道直接绑定到DataContext的语法。我没有尝试过,但因为绑定的构造函数只是采用了路径。尝试新绑定(“.”)。
BindingOperations.SetBinding(myControl, MyControlClass.Property, new Binding(...));