Skip to content

Commit 1ec5afa

Browse files
committed
Fixing issue with MahAppsBundled theme not updating colors on theme changes.
1 parent d4d542e commit 1ec5afa

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

MaterialDesignThemes.MahApps/MahAppsBundledTheme.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,11 @@ private void ThemeManagerOnThemeChanged(object sender, ThemeChangedEventArgs e)
2323
ResourceDictionary resourceDictionary = e.ResourceDictionary;
2424

2525
ITheme newTheme = e.NewTheme;
26-
26+
2727
var foreground = newTheme.Background.ContrastingForegroundColor();
28-
if (foreground == Colors.Black)
29-
{
30-
//Theme has a light color background
31-
resourceDictionary.SetMahAppsBaseTheme(BaseTheme.Light);
32-
}
33-
else if (foreground == Colors.White)
34-
{
35-
//Theme has a dark color background
36-
resourceDictionary.SetMahAppsBaseTheme(BaseTheme.Dark);
37-
}
28+
29+
BaseTheme baseTheme = foreground == Colors.Black ? BaseTheme.Light : BaseTheme.Dark;
30+
resourceDictionary.SetMahApps(newTheme, baseTheme);
3831
}
3932
}
4033
}

0 commit comments

Comments
 (0)