22using System . Linq ;
33using System . Windows ;
44using System . Windows . Media ;
5- using MahApps . Metro ;
5+ using ControlzEx . Theming ;
66using MaterialDesignColors ;
77using MaterialDesignColors . ColorManipulation ;
88using MaterialDesignThemes . Wpf ;
9+ using Theme = ControlzEx . Theming . Theme ;
910
1011namespace MaterialDesignThemes . MahApps
1112{
@@ -57,9 +58,8 @@ static ResourceDictionary GetResourceDictionary(ITheme theme, PrimaryColor prima
5758 {
5859 string baseColorScheme = baseTheme . GetMahAppsBaseColorScheme ( ) ;
5960 string colorScheme = $ "MaterialDesign.{ primaryColor } .{ secondaryColor } ";
60-
6161 ResourceDictionary rv ;
62- if ( ThemeManager . Themes . FirstOrDefault ( x => x . BaseColorScheme == baseColorScheme && x . ColorScheme == primaryColor . ToString ( ) ) is global :: MahApps . Metro . Theme mahAppsTheme )
62+ if ( ThemeManager . Current . Themes . FirstOrDefault ( x => x . BaseColorScheme == baseColorScheme && x . ColorScheme == primaryColor . ToString ( ) ) is Theme mahAppsTheme )
6363 {
6464 rv = mahAppsTheme . Resources ;
6565 rv . SetMahApps ( theme , baseTheme ) ;
@@ -70,16 +70,21 @@ static ResourceDictionary GetResourceDictionary(ITheme theme, PrimaryColor prima
7070 rv [ GeneratedKey ] = GeneratedKey ;
7171 rv . SetMahApps ( theme , baseTheme ) ;
7272
73- rv [ "Theme.Name" ] = $ "MaterialDesign.{ baseColorScheme } .{ primaryColor } .{ secondaryColor } ";
74- rv [ "Theme.DisplayName" ] = $ "Material Design { primaryColor } with { secondaryColor } ";
75- rv [ "Theme.ColorScheme" ] = colorScheme ;
76- ThemeManager . AddTheme ( rv ) ;
73+ string themeName = $ "MaterialDesign.{ primaryColor } .{ secondaryColor } .{ baseColorScheme } ";
74+ string displayName = $ "Material Design { primaryColor } with { secondaryColor } ";
75+ rv [ Theme . ThemeNameKey ] = themeName ;
76+ rv [ Theme . ThemeDisplayNameKey ] = displayName ;
77+ rv [ Theme . ThemeColorSchemeKey ] = colorScheme ;
78+ rv [ Theme . ThemeBaseColorSchemeKey ] = baseColorScheme ;
79+ var themeInstance = new Theme ( new LibraryTheme ( rv , null ) ) ;
80+ rv [ Theme . ThemeInstanceKey ] = themeInstance ;
81+ ThemeManager . Current . AddTheme ( themeInstance ) ;
7782
7883 return rv ;
7984 }
8085 }
8186
82- private void ThemeManagerOnThemeChanged ( object sender , ThemeChangedEventArgs e )
87+ private void ThemeManagerOnThemeChanged ( object sender , Wpf . ThemeChangedEventArgs e )
8388 {
8489 ResourceDictionary resourceDictionary = e . ResourceDictionary ;
8590
0 commit comments