Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
How to change the background color of "ButtonTool"
posted

Hi I am trying to change the "ButtonTool" background color on specific conditions.

But the "ButtonTool" fails to update the color.

Can any one give me a solution to it?

 

thanks in advance .

 

Parents
  • 54937
    Offline posted

    The Ribbon buttons have many different looks depending on where they are located (e.g. ribbon group, application menu footer toolbar, in a button group), whether they are large or small and based on various state information (checked, pressed, mouseover, disabled, normal). To express that directly with the xaml for the various button tools would require lots of different templates and lots of elements. To be more performant the rendering of the borders and background of the button tools is done by the RibbonButtonChrome class. This class obtains the colors that it will use from dynamic resources for brushes for different states; those brushes vary depending on the theme being used. So for example a small regular (i.e. not a toggle) enabled button tool in the ribbon group (not in a button group) would use RibbonBrushKeys.ButtonToolPressedBorderDarkFillKey, ButtonToolPressedInnerBorderFillKey and ButtonToolPressedCenterFillKey keyed brushes when pressed, the RibbonBrushKeys.ButtonToolHoverBorderDarkFillKey, ButtonToolHoverCenterFillKey and ButtonToolHoverBorderLightFillKey keyed brushes when the mouse is over them and otherwise is transparent when not pressed/hot-tracked. Therefore it is not really possible to use the Background property. You would either need to retemplate the tool to provide the look you want or you could add brushes to the Resources of the button with these keys.

Reply Children