question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to apply a new theme using the MaterialThemeBase

See original GitHub issue

Hey there, I’m updating my code from using the old PaletteHelper to the new MaterialTheme but cannot find a way to update the current theme. I simply want to toggle between dark/light, everything worked as expected previously…

My App.xaml:

  <Application.Styles>
    <themes:MaterialThemeBase />
    <StyleInclude Source="avares://Material.Avalonia/Material.Avalonia.Templates.xaml" />
    <StyleInclude Source="avares://Material.Icons.Avalonia/App.xaml" />
    <StyleInclude Source="/Styles/Styles.xaml" />
  </Application.Styles>

My OnFrameworkInitializationCompleted:

  var theme = Theme.Create(Theme.Light, Primary, Accent);
  var themeBootstrap = this.LocateMaterialTheme<MaterialThemeBase>();
   themeBootstrap.CurrentTheme = theme;

My toggle theme code:

var materialTheme = Application.Current.LocateMaterialTheme<MaterialThemeBase>();
materialTheme.CurrentTheme.SetBaseTheme(Theme.Dark);

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
teocomicommented, Jun 2, 2022

It does indeed work! Sorry for opening a non-issue & thanks for checking 💥

1reaction
teocomicommented, May 28, 2022

Hey @SKProCH thanks for your support! I just tried unfortunately this doesn’t seem to work either. I can put together a quick sample app if that helps…

And thanks for the great library!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating new themes using the Site Editor
Click on the name of the template or template part to open it in the Site Editor. You can also use the Add...
Read more >
How to Install WP Themes Manually [+ 2 Other Methods]
Installing a WordPress Theme Through the Theme Directory · 1. Log in to your WordPress account. · 2. Navigate to Appearance > Themes....
Read more >
Beginners Guide: How to Install a WordPress Theme
First, you need to download the theme .zip file to your computer. After that, you need to unzip the file. This will create...
Read more >
How to change Button's hover color after ...
Hi, I've created a custom skin based on Material and changed the colour to blue. However the button hover effect, and the callback...
Read more >
Upload a Theme
Check for demo content you can add with your theme. Go to Appearance → Customize to check for any theme setup options you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found