开发者

How do I bind to a property on the DataContext without using a DependencyProperty?

开发者 https://www.devze.com 2023-03-01 22:03 出处:网络
I know how to bind to a DependencyProperty and how to create my own DependencyProperty\'s.Is there a开发者_如何学C way to get the value from the DataContext of the control in its code behind using the

I know how to bind to a DependencyProperty and how to create my own DependencyProperty's. Is there a开发者_如何学C way to get the value from the DataContext of the control in its code behind using the binding system (i.e. not reflection)? I'm considering a method of binding directly to the code behind rather than having to bind through the interface. I know that I could just create a DependencyProperty and bind to that, but I was just wondering if there was a way using a BindingExpression or something to forgo having to create a DependencyProperty.

I'm using Silverlight 4 with Expression Blend 4 and Visual Studio 2010.


No, the only two ways you could do this are via reflection, or by creating a 'local' dependency property and binding that to your DataContext by some expression. There is no other 'magic' way!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号