MahApps / mahapps.com

New web site for MahApps.Metro
https://mahapps.com
MIT License
19 stars 32 forks source link

Transition from ThemeManager to ControlzEx #8

Closed tokm closed 4 years ago

tokm commented 4 years ago

I used MahApps.Metro.ThemeManager.AddAccent in my project to add custom accents. How do I do the same thing now since ThemeManager in MahApps.Metro has been removed in 2.0? I looked for documentation on this but was not able to find anything useful.

timunie commented 4 years ago

@punker76 should I write something down for this?

tokm commented 4 years ago

@punker76 should I write something down for this?

Is there documentation on ControlzEx ThemeManager? I see basic documentation on github, but nothing regarding ThemeManager funcationality. I loaded a ton of dynamic accents from the old ThemeManager and I can't upgrade MahApps.Metro to 2.0 until I figure out how to do the same using the ThemeManager in ControlzEx.

I had xaml resources that were full of different color accents. I loaded those at runtime and let the user choose their theme. Is this functionality gone completely or does ThemeManager have this ability?

For example: I would load accents at startup: MahApps.Metro.ThemeManager.AddAccent("Dark", new Uri("pack://application:,,,/SSHS_VP;component/Resources/CustomAccents/DarkAccent.xaml")); MahApps.Metro.ThemeManager.AddAccent("Tomato", new Uri("pack://application:,,,/SSHS_VP;component/Resources/CustomAccents/Tomato.xaml")); MahApps.Metro.ThemeManager.AddAccent("BlueFade", new Uri("pack://application:,,,/SSHS_VP;component/Resources/CustomAccents/BlueFade.xaml"));

Then apply the one the user picked: MahApps.Metro.Accent accent = cboThemeChooser.SelectedItem as MahApps.Metro.Accent; var theme = MahApps.Metro.ThemeManager.AppThemes.Where(x => x.Name == "BaseLight").Single(); MahApps.Metro.ThemeManager.ChangeAppStyle(Application.Current, accent, theme);

timunie commented 4 years ago

Hi @tokm , I think the documentation is not up to date, but will be soon. If you just want to change the AccentColors then you can do it very simple by passing a Color the the ThemeMananger. I have done this here: https://github.com/timunie/TimsWpfControls/blob/d280ceade6c6243ea533d519b4fdd9924ea9dfd6/TimsWpfControls/TimsWpfControls_Demo/Model/MainViewModel.cs#L127

I hope this helps for now & Happy coding Tim

tokm commented 4 years ago

I think I can alter my code to use the methods below. Thanks for the help.

Theme new Theme = new Theme("Custom", "Custom", BaseTheme, AccentColorName, AccentColor, new SolidColorBrush(AccentColor), true, false);

        newTheme.Resources["MahApps.Colors.Highlight"] = HighlightColor;
        newTheme.Resources["MahApps.Brushes.Highlight"] = new SolidColorBrush(HighlightColor);

        ThemeManager.Current.ChangeTheme(App.Current, newTheme);
timunie commented 4 years ago

@tokm please reopen this issue, it should be added to the documentation anyway. Thanks.

punker76 commented 4 years ago

@tokm Here you go https://mahapps.com/docs/themes/