How to override the text Normal foreground brush?

Themes, Shared, and Core Libraries for Avalonia Forum

Posted 2 months ago by Michael Janulaitis - Corner Bowl Software
Avatar

The default font is too light and washes out IMHO.  The DefaultForegroundBrushMax is prefect.  How can I override the default brush to use the max brush without adding the style class to every control?  Also when running in dark mode, I want to do the opposite and make the font whiter.

Comments (6)

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If you have specific brushes you'd like to use, you can override our resources in Application.Resources like this:

<Application.Resources>
	<ResourceDictionary>
		<ResourceDictionary.ThemeDictionaries>
			<ResourceDictionary x:Key="Light">
				<Brush x:Key="{actipro:ThemeResourceKey DefaultForegroundBrush}">#ff0000</Brush>
			</ResourceDictionary>
			<ResourceDictionary x:Key="Dark">
				<Brush x:Key="{actipro:ThemeResourceKey DefaultForegroundBrush}">#00ff00</Brush>
			</ResourceDictionary>
		</ResourceDictionary.ThemeDictionaries>
	</ResourceDictionary>
</Application.Resources>

There I'm setting the colors to red and green but you could use any shade.  The 5 default foreground brushes are the following and can all be set like above:

  • DefaultForegroundBrush
  • DefaultForegroundBrushMax
  • DefaultForegroundBrushSecondary
  • DefaultForegroundBrushTertiary
  • DefaultForegroundBrushDisabled


Actipro Software Support

Posted 2 months ago by Michael Janulaitis - Corner Bowl Software
Avatar

OK thanks.  How can I find the actual values for the brushes?

[Modified 2 months ago]

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

The easiest way to browse all the available theme resources is to use the Theme Resource Browser utility in our Sample Browser application:

https://www.actiprosoftware.com/docs/controls/avalonia/utilities/theme-resource-browser

If you're trying to lookup current values at run-time in code, the following topic dicusses that:

https://www.actiprosoftware.com/docs/controls/avalonia/themes/theme-assets#resource-keys-in-code


Actipro Software Support

Posted 2 months ago by Michael Janulaitis - Corner Bowl Software
Avatar

I am unable to see the actual values in the theme browser.  Am I missing the button to expose that information?  I do not need to lookup the values in runtime.

Answer - Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

To the left of each theme resource is a preview of it.  Brushes will have a color swatch.  Thickness and CornerRadius values will render a shape using the related value.  If you hover the pointer over the preview, you'll see the actual value.  For instance, if you hover over the color swatch you'll see a tooltip with the hex value of the color.


Actipro Software Support

Posted 2 months ago by Michael Janulaitis - Corner Bowl Software
Avatar

Thanks!

[Modified 2 months ago]

Add Comment

Please log in to a validated account to post comments.