c# - How to disable mouse over effect visibility temporarily on button click? -


for simplicity's sake, let's program's buttons white when "off" , green when "on". buttons change color light blue when mouse hovering on them. currently, when button clicked, button color remains light blue until mouse no longer hovering on button, , (when mouse has moved away , no longer hovering on button) button's green or white background displayed. code hover effect , button background currently...

<controltemplate targettype="{x:type button}">   <border x:name="bdr" cornerradius="22" margin="3" borderthickness="2.5" borderbrush="black" background="{templatebinding background}">      <contentpresenter verticalalignment="center" horizontalalignment="center" contentsource="content" />   </border>   <controltemplate.triggers>      <trigger property="ismouseover" value="true">          <setter targetname="bdr" property="background" value="#abbec9"/>      </trigger> 

i need buttons new background displayed (even if mouse still hovering on button) after click event. having trouble implementing this.

i've tried multidatatrigger below, hover color flashes on click white , background color no longer displays when mouse no longer hovering on button, code wrong.

<multidatatrigger>   <multidatatrigger.conditions>      <condition binding="{binding elementname=bdr, path=ismouseover}" value="true" />   </multidatatrigger.conditions>      <setter targetname="bdr" property="background" value="#abbec9" />   </multidatatrigger> <multidatatrigger>    <multidatatrigger.conditions>       <condition binding="{binding elementname=bdr, path=ismouseover}" value="false" />    </multidatatrigger.conditions>       <setter targetname="bdr" property="background" value="white" />                             </multidatatrigger> 

any appreciated.

you'll have handle yourself, minimal amount of procedural code (e.g. boolean property).

if want keep things simple instead show state in way, leveraging borderbrush display button's background.

here full template:

<controltemplate targettype="{x:type button}">     <border x:name="bdr" cornerradius="22" margin="3" borderthickness="2.5" borderbrush="black" background="{templatebinding background}">         <contentpresenter verticalalignment="center" horizontalalignment="center" contentsource="content" />     </border>     <controltemplate.triggers>         <trigger property="ismouseover" value="true">             <setter targetname="bdr" property="background" value="#abbec9"/>         </trigger>         <trigger property="ismouseover" value="true">             <setter targetname="bdr" property="borderbrush" value="{binding relativesource={relativesource ancestortype=button},path=background}"/>         </trigger>     </controltemplate.triggers> </controltemplate> 

Comments