c# - WPF Menu Item doesn't get closed -
i want re-style contextmenu following style
<controltemplate x:key="{x:static menuitem.submenuitemtemplatekey}" targettype="menuitem"> <border x:name="templateroot" borderbrush="{templatebinding borderbrush}" borderthickness="{templatebinding borderthickness}" background="{templatebinding background}" height="22" snapstodevicepixels="true"> <grid> <button> <contentpresenter name="headerhost" contentsource="header" recognizesaccesskey="true"/> </button> </grid> </border> <controltemplate.triggers> <trigger property="ishighlighted" value="true"> <setter property="background" targetname="templateroot" value="transparent"/> <setter property="borderbrush" targetname="templateroot" value="{staticresource menuitem.highlight.border}"/> </trigger> <trigger property="isenabled" value="false"> <setter property="foreground" value="{staticresource disabledforegroundbrush}"/> </trigger> </controltemplate.triggers> </controltemplate>
once click on context menu item triggers call menu stays on screen. how can trigger closing logic?
thanks
the button
handling click event , stopping bubbling visual tree menuitem
.
setting ishittestvisible
on button stop button
handling click event, stop mouseover/pressed
styling.
<button ishittestvisible="false"> <contentpresenter name="headerhost" contentsource="header" recognizesaccesskey="true"/> </button>
Comments
Post a Comment