0

I use <FluentTheme Mode="Dark" /> for my application. I really like it but i want to change part of the design. For example swap the background to a bright pink.

I tried overriding the style like this:

<Application xmlns="https://github.com/avaloniaui"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:local="using:Avalonia.Test"
         x:Class="Avalonia.Test.App">
<Application.DataTemplates>
    <local:ViewLocator />
</Application.DataTemplates>

<Application.Styles>
    <FluentTheme Mode="Dark" />
    <Style>
        <Style.Resources>
            <Color x:Key="ThemeBackgroundColor">#CCFF0068</Color>
            <SolidColorBrush x:Key="ThemeBackgroundBrush" Color="{DynamicResource ThemeBackgroundColor}" />
        </Style.Resources>
    </Style>
</Application.Styles>

But sadly it doesnt work. No errors are thrown but the change doesnt apply. Does anyone have a tip on how to only change part of the FluentTheme of avalonia?

Hyding
  • 3
  • 1
  • 2

1 Answers1

1

For the Fluent theme the resource name is SystemControlBackgroundAltHighBrush. I suggest overriding the resource instead of using style in your App.xaml -

  <Application.Resources>
        <SolidColorBrush x:Key="SystemControlBackgroundAltHighBrush" Color="#CCFF0068"/>
    </Application.Resources>
Adir Hudayfi
  • 136
  • 1
  • 7
  • Thanks alot! That works. I was wondering if there is any list of all the available keys? – Hyding Sep 12 '21 at 08:42
  • Yes, sorry forgot to link it - https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml – Adir Hudayfi Sep 12 '21 at 08:59
  • Hi Guys - Is this still correct on how to override colors in the styles. I tried this but the colors wont change. - Never Mind - I needed to place the Application.Resources section above the Application.Styles Section - then it worked :) – Roddles Mar 07 '23 at 09:00