c# - Tooltip style. Can't bind to datacontext -
i have 1 problem tooltip. want add templated tooltip button information inside.
here button tooltip, datacontext bounded viewmodel:
<fluent:button datacontext="{binding newconnections, source={staticresource locator}}" command="{binding addcloudstorageaccount}" header="add account"> <fluent:button.largeicon> <image source="pack://application:,,,/icons;component/ui/v1/add_account.png" width="48"/> </fluent:button.largeicon> <fluent:button.tooltip> <tooltip datacontext="{binding userinput.addaccountsbuttoninfo, source={staticresource locator}}" style="{staticresource buttontooltip}"></tooltip> </fluent:button.tooltip> </fluent:button>
style:
<style targettype="tooltip" x:key="buttontooltip"> <setter property="contenttemplate"> <setter.value> <datatemplate> <border background="lightyellow" borderthickness="0.5" borderbrush="maroon"> <stackpanel orientation="vertical" margin="3"> <textblock x:name="_txttext" text="{binding title}"></textblock> <textblock x:name="_txtdescription" margin="0 10 0 0" text="{binding description}"></textblock> <textblock x:name="_txthotkeydescription" margin="0 10 0 0" text="{binding hotkeydescription}"></textblock> </stackpanel> </border> </datatemplate> </setter.value> </setter> </style>
i set breakpoints see if viewmodel accessed. , it's ok. properties title not accessed @ , see empty rectangle without text
do have ideas?
just resolved it(set datacontext in border). maybe interested in:
<style targettype="tooltip" x:key="buttontooltip"> <setter property="contenttemplate"> <setter.value> <datatemplate> <border background="lightyellow" borderthickness="0.5" borderbrush="maroon" datacontext="{binding path=datacontext, relativesource={relativesource findancestor, ancestortype={x:type tooltip}}}"> <stackpanel orientation="vertical" margin="3"> <textblock x:name="_txttext" text="{binding title}"></textblock> <textblock x:name="_txtdescription" margin="0 10 0 0" text="{binding description}"></textblock> <textblock x:name="_txthotkeydescription" margin="0 10 0 0" text="{binding hotkeydescription}"></textblock> </stackpanel> </border> </datatemplate> </setter.value> </setter> </style>
Comments
Post a Comment