Skip to content

How do I set different primary/secondary colors and specific brushes for Light and Dark themes? #247

Answered by SKProCH
NoizeDaemon asked this question in Q&A
Discussion options

You must be logged in to vote

Hello. There is 2 ways:

  1. Using "native" Avalonia way. You can specify resources after MaterialTheme, so Avalonia would find it first during resources lookup. So, you need a something like this:
    <x:MaterialTheme ... />
    <Style>
      <Style.Resources>
        <ResourceDictionary>
          Here is your dictionary for Dark and Light themes
        </ResourceDictionary>
      </Style.Resources>
    </Style>
    It would work perfectly, since Avalonia will find your resources first, but doesn't have animation for switching themes.
  2. Using our themes. You need to create ITheme. You can use Theme.Create as described here or just use ctor of Theme class. After all replace MaterialTheme with MaterialThemeBase in you App.axaml,…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@NoizeDaemon
Comment options

@SKProCH
Comment options

@NoizeDaemon
Comment options

Answer selected by NoizeDaemon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants