开发者

wpf resource binding to another element's property

I'm new to WPF so pardon me if i'm asking something stupid. I have an class named Per开发者_JS百科son in my application. Can i do something like

<local:Person x:Key="p" BirthYear="{Binding Path=Value, ElementName=year}"  /> 

where 'year' is a control?


you are probably better off inverting your binding and binding the control to your class

<Control Value="{Binding Path=BirthYear}" DataContext="{StaticResource p}"/>


No, you can't because resources are not part of the same naming container (and are added differently to the visual tree).

Why do you need to store a Person (business object I assume) as a resource, but having its value coming from another control? Maybe if you explain your motivation we can help you find a better alternative.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜