win universal app - change the text color when hover on a Button in a UWP -


i trying modify text color of button when mouse hover,from black color,i used style:

  <style  x:key="buttonmenustyle"     targettype="button">         <setter property="foreground" value="#393185"/>         <setter property="template">             <setter.value>                 <controltemplate targettype="button">                     <grid>                         <visualstatemanager.visualstategroups>                             <visualstategroup x:name="commonstates">                                 <visualstate x:name="normal"/>                                 <visualstate x:name="pointerover">                                     <storyboard>                                         <coloranimation duration="0" to="#393185" storyboard.targetproperty="(textblock.foreground).(solidcolorbrush.color)" storyboard.targetname="content1" />                                     </storyboard>                                 </visualstate>                                 <visualstate x:name="pressed">                                     <storyboard>                                         <coloranimation duration="0" to="#393185" storyboard.targetproperty="(textblock.foreground).(solidcolorbrush.color)" storyboard.targetname="content1" />                                     </storyboard>                                 </visualstate>                             </visualstategroup>                         </visualstatemanager.visualstategroups>                         <grid>                             <contentpresenter x:name="content1"/>                         </grid>                     </grid>                 </controltemplate>             </setter.value>         </setter>     </style> 

but problem code, result in hover(the color on hover has changed),but text of button not displayed in left center,this result:

enter image description here

and code,to apply style on button:

<button  borderthickness="0" background="transparent" content="nouveau local" fontsize="18"  foreground="#393185"  x:name="res9"  horizontalalignment="left"   height="50" grid.column="1" style="{binding source={staticresource buttonmenustyle}}"/> 

please how can correct code,to have text centred in left help

if asking vertically center content of button, can this:

<contentpresenter x:name="content1" verticalalignment="center"/> 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -