i have created style custom control
(buttonanalysiscontrol). working except tooltip
. when move mouse on menuitem
tooltip
doesn't show up. inspected menuitems
snoop
and tooltip
value correctly set. how can make tooltip work? bonus question: how can remove border
in contextmenu
?
contextmenu:
generic.xaml style
<style targettype="anal:buttonanalysiscontrol"> <setter property="template"> <setter.value> <controltemplate targettype="anal:buttonanalysiscontrol"> <controltemplate.triggers> <eventtrigger routedevent="click"> <beginstoryboard> <storyboard> <booleananimationusingkeyframes storyboard.targetname="contextmenu" storyboard.targetproperty="(contextmenu.isopen)"> <discretebooleankeyframe keytime="00:00:00" value="true"/> </booleananimationusingkeyframes> </storyboard> </beginstoryboard> </eventtrigger> </controltemplate.triggers> <controltemplate.resources> <anal:custommultivalueconvertor x:key="custommultivalueconvertor"/> <anal:inttopercentagebrushconvertor x:key="inttopercentagebrushconvertor"/> </controltemplate.resources> <grid> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition height="*"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*" /> </grid.columndefinitions> <grid.contextmenu> <contextmenu name="contextmenu" isopen="false" placement="top" placementtarget="{binding relativesource={relativesource templatedparent}}"> <contextmenu.itemssource> <binding relativesource="{relativesource templatedparent}" path="childcommands"/> </contextmenu.itemssource> <contextmenu.itemcontainerstyle> <style targettype="{x:type menuitem}"> <setter property="menuitem.header"> <setter.value> <multibinding converter="{staticresource custommultivalueconvertor}"> <binding path="percentage" /> <binding path="viewcommand.command.text" /> </multibinding> </setter.value> </setter> <setter property="menuitem.isenabled" value="false"/> <setter property="menuitem.background" value="{binding percentage, converter={staticresource inttopercentagebrushconvertor}}"/> <setter property="menuitem.padding" value="0"/> <setter property="menuitem.borderthickness" value="0"/> <setter property="menuitem.tooltip" value="123"/> </style> </contextmenu.itemcontainerstyle> <contextmenu.itemspanel> <itemspaneltemplate> <virtualizingstackpanel orientation="vertical"/> </itemspaneltemplate> </contextmenu.itemspanel> </contextmenu> </grid.contextmenu> <textblock textalignment="center" verticalalignment="stretch" foreground="{staticresource commandbarforeground}" background="{staticresource mainforegroundbrush}" fontfamily="{staticresource fontfamily}" fontsize="10" grid.column="0" grid.row="0"> <textblock.text> <binding path="text" stringformat="{}{0}%" relativesource="{relativesource templatedparent}" /> </textblock.text> </textblock> <rectangle grid.column="0" grid.row="1"> <rectangle.fill> <binding path="backgroundbrush" relativesource="{relativesource templatedparent}" /> </rectangle.fill> </rectangle> </grid> </controltemplate> </setter.value> </setter> </style>
i found answer: tooltip didn't show because menuitem disabled.
adding line menuitem style fixed it:
<setter property="tooltipservice.showondisabled" value="true" />
Comments
Post a Comment