binding - WPF Styles and Tooltips Question -
i have style using make dynamic tooltips on text boxes so.
<style targettype="{x:type textbox}"> <setter property="minwidth" value="100"/> <style.triggers> <trigger property="validation.haserror" value="true"> <!-- item of interest --> <setter property="tooltip"> <setter.value> <multibinding converter="{staticresource errormessageconverter}"> <binding relativesource="{relativesource self}" path="tag"/> </multibinding> </setter.value> </setter> </trigger> </style.triggers> </style>
this works well, if want use more complex tooltip can't figure out how bind 'tag' anymore converter value. example;
... <setter property="tooltip"> <setter.value> <stackpanel> <textblock> <textblock.text> <multibinding converter="{staticresource errormessageconverter}"> <!-- item of interest --> <binding relativesource=" goes here?? "/> </multibinding> </textblock.text> </textblock> <image/> </stackpanel> </setter.value> </setter> ...
i have tried several flavors of 'findancestor' , not relative source, can't work. ideas??
update: 12-29-2010 : here correct code, answer provided our friend goblin below. works perfectly!
... <setter property="tooltip"> <setter.value> <!-- item of interest --> <tooltip datacontext="{binding path=placementtarget, relativesource={x:static relativesource.self}}"> <stackpanel> <image/> <textblock> <textblock.text> <multibinding converter="{staticresource errormessageconverter}"> <binding path="tag"/> </multibinding> </textblock.text> </textblock> </stackpanel> </tooltip> </setter.value> </setter> ...
see karl shifflett full explanation of how inherit datacontext of 'owning' control tooltip: http://karlshifflett.wordpress.com/2007/12/29/wpf-sample-series-data-binding-in-tooltip/
it isn't textbook stuff :)
Comments
Post a Comment