wpf - Custom button style is not working? -


i'm trying style button, ends not showing when apply custom style, content (the button's text) visible. how declare style:

    <color x:key="normalcolor" a="255" r="60" g ="158" b="184"/>     <color x:key="hovercolor" a="255" r="74" g ="177" b="204"/>     <color x:key="pressedcolor" a="255" r="26" g ="115" b="138"/>      <solidcolorbrush x:key="normalbrush" color="{staticresource normalcolor}" />     <solidcolorbrush x:key="hoverbrush" color="{staticresource hovercolor}" />     <solidcolorbrush x:key="pressedbrush" color="{staticresource pressedcolor}" />      <style x:key="flatbutton" targettype="button">         <setter property="overridesdefaultstyle" value="true"/>         <setter property="fontfamily" value="segoe ui"/>         <setter property="background" value="{staticresource normalbrush}"/>         <setter property="foreground" value="#000000"/>          <setter property="template">             <setter.value>                 <controltemplate targettype="{x:type button}">                      <contentpresenter horizontalalignment="center" verticalalignment="center" name="content"/>                      <controltemplate.triggers>                          <trigger property="ismouseover" value="true">                             <setter property="background"  value="{staticresource hoverbrush}" />                             <setter property="foreground" value="#000000" />                         </trigger>                          <trigger property="ispressed" value="true">                             <setter property="background" value="{staticresource pressedbrush}" />                             <setter property="foreground" value="#000000" />                         </trigger>                          <trigger property="isenabled" value="false">                             <setter property="background" value="{staticresource normalbrush}" />                             <setter property="foreground" value="#000000" />                             <setter property="opacity" value="0.5" />                                                         </trigger>                      </controltemplate.triggers>                 </controltemplate>             </setter.value>         </setter>     </style>  </window.resources> 

and here how use it:

<button content="connect" command="model:globalcommands.connecttodbcommand" style="{staticresource flatbutton}"/> 

can tell me went wrong this? thank you!

there nothing in controltemplate use background. put contentpresenter inside border (for example) , use templatebinding bind background

<border background="{templatebinding background}">     <contentpresenter horizontalalignment="center" verticalalignment="center" name="content"/> </border> 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -