How to get back to the default foregound themed brush?

Ribbon for WPF Forum

Posted 3 years ago by Procam
Version: 21.1.1
Avatar

Hi,

I have a form with more textboxes with default foreground in theme Metro.Dark. For some reason (to signalize the text was modified), I had to change the foreground to another brush. Later, I need again to set the default foreground even the theme was changed to Metro.Light in the meantime. How to get the default foreground color? Thx!

Comments (4)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

TextBox controls in our themes currently have this default Foreground:

<Setter Property="Foreground" Value="{DynamicResource {x:Static themes:AssetResourceKeys.ContainerForegroundLowNormalBrushKey}}" />

You'd need to do something like this to reestablish the DynamicResource via code:

textBox.SetResourceReference(TextBox.ForegroundProperty, AssetResourceKeys.ContainerForegroundLowNormalBrushKey);


Actipro Software Support

Posted 3 years ago by Procam
Avatar

Hello,

I meant that when it changes to theme Metro.Dark, what is the foregound brush for the textbox? And vice-versa to Metro.Light.

Answer - Posted 3 years ago by Procam
Avatar

Yes, this way:
Brush b = Application.Current.FindResource(AssetResourceKeys.ControlBackgroundNormalBrushKey) as Brush;

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If you get our latest version (released Friday) and run the Theme Designer app, you can load up the themes you are interested in from the Presets menu.  Then open the Resource Browser tab and filter the resource list down by ContainerForegroundLowNormalBrushKey.  If you right-click the item in the list, there now is a Copy Color Value menu item you can use to get the color in the currently-loaded theme.  If you only care about the color value used, that is an alternate way to get the brush's color value.


Actipro Software Support

The latest build of this product (v24.1.1) 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.