ChangeAppStyle only works once
See original GitHub issueI try to implement a Light/Dark-Switch. When i press the button, ChangeAppStyle works once. When i press it again, nothing happens. No error, no change (only the background). It doesn’t matter, which Theme i choose … if i use BaseDark in App.xaml, i can change once to BaseLight, but not back to BaseDark.
private void lightDARK_Click(object sender, RoutedEventArgs e)
{
try
{
MainWindow mw = (MainWindow)Application.Current.MainWindow;
SolidColorBrush color;
if (mw.Background.ToString() == "#FF696969")
{
ThemeManager.ChangeAppStyle(this, ThemeManager.GetAccent("Blue"), ThemeManager.GetAppTheme("BaseLight"));
color = Brushes.LightGray;
}
else
{
ThemeManager.ChangeAppStyle(this, ThemeManager.GetAccent("Blue"), ThemeManager.GetAppTheme("BaseDark"));
color = Brushes.DimGray;
}
mw.Background = color;
}
catch (Exception ex)
{
throw new Exception("Error: " + ex.Message);
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
WPF MahApps Change style of Window notworking for ...
ChangeAppStyle will not work then i use one of MahApps colors resource file like blue.xaml . Anyway the lable color is Blue in...
Read more >Styles
This guide will introduce you to the many accents and themes that Fluent.Ribbon has and how to create your own. All of Fluent.Ribbon...
Read more >Release 1.6.0
Add new (readonly) ItemFocusVisualStyle dependency property which will be re-created if one of these properties are changed: OpenPaneLength , ...
Read more >News
ChangeAppStyle from separate thread doesn't take effect every 4th time; #2966 [Only visual] PasswordBox bug; #2963 WindowCommands with ...
Read more >[Solved]-Mahapps, themes not applying to user controls-wpf
After that I think you need to look at the Theme Manager. ... ChangeAppStyle(Application. ... Two web user controls are not working on...
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 Free
Top 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
Thanks very much! Application.Current works perfectly! 😃