New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThemeManager.ChangeAppStyle from separate thread doesn't take effect every 4th time #2972

Closed
Dimigergo opened this Issue May 22, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@Dimigergo

Dimigergo commented May 22, 2017

Hello!

When I call ThemeManager.ChangeAppStyle from a separate thread the application style is not changed every 4th time, and ThemeManager.IsThemeChanged is not called.

I have a small example to reproduce this issue.
[https://github.com/Dimigergo/MahappsThemeManager]

There is a log file, called "valami.log" which contains:

2017.05.22. 12:43:29 - Changing theme to Red
2017.05.22. 12:43:29 - Change theme: NewTheme: Red Theme changed.
2017.05.22. 12:43:34 - Changing theme to Amber
2017.05.22. 12:43:34 - Current theme from args: Amber
2017.05.22. 12:43:34 - Current theme from detection: Amber
2017.05.22. 12:43:34 - Change theme: NewTheme: Amber Theme changed.
2017.05.22. 12:43:39 - Changing theme to Emerald
2017.05.22. 12:43:39 - Current theme from args: Emerald
2017.05.22. 12:43:39 - Current theme from detection: Emerald
2017.05.22. 12:43:39 - Change theme: NewTheme: Emerald Theme changed.
2017.05.22. 12:43:44 - Changing theme to Red
2017.05.22. 12:43:44 - Current theme from args: Red
2017.05.22. 12:43:44 - Current theme from detection: Amber
2017.05.22. 12:43:44 - Change theme: NewTheme: Red Theme changed.
2017.05.22. 12:43:49 - Changing theme to Amber
2017.05.22. 12:43:49 - Change theme: NewTheme: Amber Theme changed.
2017.05.22. 12:43:54 - Changing theme to Emerald
2017.05.22. 12:43:54 - Current theme from args: Emerald
2017.05.22. 12:43:54 - Current theme from detection: Emerald
2017.05.22. 12:43:54 - Change theme: NewTheme: Emerald Theme changed.

When Current theme from args and Current theme from detection are appeared, the accent of the application is ok.

Environment:
Mahapps.Metro 1.5.0.23
Windows 8.1 64bit
Visual Studio 2015 Update 3
.NET Framework 4.5.1 - 4.6.1

Thanks in advance!

@Dimigergo Dimigergo changed the title from ThemeManager.ChangeAppStyle from separate thread doen't take effect every 4th time to ThemeManager.ChangeAppStyle from separate thread doesn't take effect every 4th time Jun 2, 2017

@batzen

This comment has been minimized.

Contributor

batzen commented Jun 21, 2017

As i just ported ThemeManager to Fluent.Ribbon i will have a look at this issue.

@batzen

This comment has been minimized.

Contributor

batzen commented Jun 21, 2017

Ok, this is partially cause by a mistake you made and a "bug" in ThemeManager.

You add all themes you use in App.xaml whereas you only should add one. If you only add one, the issue is gone.

This kind of issue is caused because ThemeManager does not search through the merged dictionaries like wpf does. Which means that wpf searches/applies them in reverse order which means that the last dictionary you merge wins. ThemeManager does not apply this reversed order.
This was the first thing i changed when i ported ThemeManager to Fluent.Ribbon and i will bring those fixes to MahApps in the near future.

@Dimigergo

This comment has been minimized.

Dimigergo commented Jun 22, 2017

Oh, thanks, it works in this way, so it is a good solution for me. :)

@Dimigergo Dimigergo closed this Jun 22, 2017

@batzen

This comment has been minimized.

Contributor

batzen commented Jun 23, 2017

This issue will be fixed if #2992 is merged.

@punker76 punker76 added this to the 1.6.0 milestone Jun 28, 2017

@punker76 punker76 added the Bug label Feb 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment