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.

ChangeAppStyle only works once

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DerKiLLacommented, Jul 2, 2019

Thanks very much! Application.Current works perfectly! 😃

0reactions
punker76commented, Jul 2, 2019

mahapps_change_theme_sample_2

Read more comments on GitHub >

github_iconTop 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 >

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