What's the code-behind equivalent of this code?
<SomeControl SomeProperty="{Binding}"/>
(If I wanted to do that in the code-behind of SomeControl instead of in the consumer's XAML.)
That is, how do I construct a Binding object such that I bind directly to the DataContext of my current object, instead of to some property?
由于{Binding}
只是{Binding Path=.}
的快捷方式,因此它应该与
SomeControl.SetBinding(SomeControl.SomeProperty, new Binding("."));
看看BindingOperations.SetBinding :
BindingOperations.SetBinding(myControl, MyControlClass.Property, new Binding(...));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.