WPF: How do I bind the ToolTip property to the value of a siblings ToolTip property?
Assume two controls:
开发者_如何学运维<ParentControl ToolTip="{GIMME ChildControl.ToolTip}">
<ChildControl ToolTip="Yay! Look at me! I'm bouncing off walls!!!"/>
</ParentControl>
It's the {GIMME ChildControl.ToolTip} I'm not sure about. I have an inkling it won't work (what is a GIMME anyway), but I'm kind of failing here.
Things I have considered:
{Binding RelativeSource=???}- but won't that look in the bound data? I want to reference the child control, not something in the bound data{StaticRecourse useSameForChildControl}- except I'm setting theToolTipproperty dynamically in the child control...
Ugly solution that will definitely work - give ChildControl a x:Name value, then bind {Binding ElementName=childElemName, Path=ToolTip}.
(Made into an answer as suggested ;))
Have you considered the MVVM Model? That would allow you to bind both of the controls to the ViewModel?
加载中,请稍侯......
精彩评论