How to apply a new theme using the MaterialThemeBase
See original GitHub issueHey 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:
- Created a year ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It does indeed work! Sorry for opening a non-issue & thanks for checking 💥
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!