QAT buttons went to "white" color

Ribbon for WPF Forum

Posted 1 year ago by Procam
Version: 22.1.5
Avatar

Hello Actipro,

I have an issue that can be reproduced also in your Sample app:

- Open the "Document Editor (similar to Word)" external sample.

- Change the theme from "Metro Black" to "Office Colorful > Red Accent"

=> Note that the Save icon in the QAT of the external sample changed from magenta color to some kind of white color

In my case I do not use a static definition as you:

<ribbon:Button Id="Save" Command="ApplicationCommands.Save" />

but the items are added this way:

RibbonButton button = new RibbonButton
{
Id = commandModel.Id,
ImageSourceLarge = renderTargetBitmap,
ImageSourceSmall = renderTargetBitmap,
Command = commandModel.Command,
CommandParameter = commandModel.CommandParameter
};

QuickAccessToolBarItems.Add(button);

where renderTargetBitmap is

RenderTargetBitmap renderTargetBitmap = converter.Convert(null, null, commandModel.ResourceName, null) as RenderTargetBitmap;

and ResourceName is a style resource:

<Style x:Key="ThemeRed" TargetType="{x:Type ContentControl}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid>
<Path Data="M0,0L32,0 32,32 0,32z" Stroke="White" StrokeThickness="1.25"
Stretch="Uniform" Fill="Red" Margin="5" RenderTransformOrigin="0.5,0.5" />
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>

How to achieve the color of my button be preserved?

Comments (1)

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

That feature is actually by design since when you have an accented title bar color (red in your case), colored icons may or may not show up well, depending which colors they use.  Therefore in those accented title bar themes, it will convert the icons to be monochrome white for you.  Office in Colorful themes does the same kind of thing by converting icons to monochrome white as well.

This feature is implemented through our DynamicImage and ImageProvider classes.  If you wish to prevent title bar icons from going monochrome when in an accented title bar, you can add this to your App.Resources to override our theme default:

xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
...
<system:Boolean x:Key="{x:Static themes:AssetResourceKeys.WindowTitleBarUseAccentBooleanKey}">False</system:Boolean>

However doing that is NOT recommended because it will likely prevent some icons from having enough contrast with the accented title bar background color, which is the reason Office does the same thing.


Actipro Software Support

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.