private void ColorsSelectorOnSelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedColor = this.ColorsSelector.SelectedItem as KeyValuePair<string, Color>?; if (selectedColor.HasValue) { var theme = ThemeManager.DetectTheme(Application.Current); ThemeManagerHelper.CreateTheme(theme.BaseColorScheme, selectedColor.Value.Value, changeImmediately: true); Application.Current?.MainWindow?.Activate(); } }
protected override void OnStartup(StartupEventArgs e) { // add custom accent and theme resource dictionaries // ThemeManager.AddAccent("CustomAccent1", new Uri("pack://application:,,,/MahAppsMetroThemesSample;component/CustomAccents/CustomAccent1.xaml")); // ThemeManager.AddAccent("CustomAccent2", new Uri("pack://application:,,,/MahAppsMetroThemesSample;component/CustomAccents/CustomAccent2.xaml")); // ThemeManager.AddAppTheme("CustomTheme", new Uri("pack://application:,,,/MahAppsMetroThemesSample;component/CustomAccents/CustomTheme.xaml")); // create custom accents ThemeManagerHelper.CreateTheme("Dark", Colors.Red, "CustomAccentDarkRed"); ThemeManagerHelper.CreateTheme("Light", Colors.Red, "CustomAccentLightRed"); ThemeManagerHelper.CreateTheme("Dark", Colors.GreenYellow); ThemeManagerHelper.CreateTheme("Light", Colors.GreenYellow); ThemeManagerHelper.CreateTheme("Dark", Colors.Indigo); ThemeManagerHelper.CreateTheme("Light", Colors.Indigo, changeImmediately: true); base.OnStartup(e); }
protected override void OnStartup(StartupEventArgs e) { // add custom accent and theme resource dictionaries ThemeManager.AddTheme(new Uri("pack://application:,,,/MahAppsMetroThemesSample;component/CustomAccents/Dark.Accent1.xaml")); ThemeManager.AddTheme(new Uri("pack://application:,,,/MahAppsMetroThemesSample;component/CustomAccents/Dark.Accent2.xaml")); ThemeManager.AddTheme(new Uri("pack://application:,,,/MahAppsMetroThemesSample;component/CustomAccents/Light.Accent1.xaml")); ThemeManager.AddTheme(new Uri("pack://application:,,,/MahAppsMetroThemesSample;component/CustomAccents/Light.Accent2.xaml")); base.OnStartup(e); MahApps.Metro.ThemeManager.IsAutomaticWindowsAppModeSettingSyncEnabled = true; MahApps.Metro.ThemeManager.SyncThemeWithWindowsAppModeSetting(); // create custom accents ThemeManagerHelper.CreateTheme("Dark", Colors.Red, "CustomAccentDarkRed"); ThemeManagerHelper.CreateTheme("Light", Colors.Red, "CustomAccentLightRed"); ThemeManagerHelper.CreateTheme("Dark", Colors.GreenYellow); ThemeManagerHelper.CreateTheme("Light", Colors.GreenYellow); ThemeManagerHelper.CreateTheme("Dark", Colors.Indigo); ThemeManagerHelper.CreateTheme("Light", Colors.Indigo, changeImmediately: true); }