Hi,
Disclaimer: i'm a WPF newbie.
That out of the way.... i created a WPF program which also supports the various themes that come with the toolkit. The number of standard themes is limited so i want to create more themes with help of the Color Tuner. If i create a theme with Color Tuner the app.xaml is succesfully updated with the new theme. If i create a 2nd theme with Color Tuner, the app.xaml file is overwritten and i lost the 1st one.
What is the best approach to create multiple themes in Color Tuner and let the user choose one of the standard or custom themes created with Color Tuner?
Hello Jacob,
Thank you for contacting Infragistics!
You can see the following links for creating and saving color tuning configuration:
Using Color Tuner
Creating and applying color tuning configurations
The following link goes over adding a resource washer to your app to use these:Adding Resource Washer
I checked all links and after a lot of trail and error i got it almost working. Based from the standard office 2010 blue theme i created 2 more theme's with the help of Color Tuner. I want to be able to let the user choose a theme. For the most part i go it working but somehow the comboeditor keep the default theme. See the code below. Can you tell me what's wrong with it?
Application.Current.Resources.MergedDictionaries.Clear(); WinThemes.ResourceWasher resw = new WinThemes.ResourceWasher(); System.Windows.Media.Color _washcolor = new System.Windows.Media.Color(); if (_theme == "office2010green") { _washcolor = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FF718C39"); //resw.WashColor = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FF718C39"); } else if (_theme == "office2010grey") { _washcolor = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FF6D6D6D"); //resw.WashColor = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FF6D6D6D"); } ResourceDictionary myResourceDictionary = new ResourceDictionary(); myResourceDictionary.Source = new Uri("Themes\\Office2010Blue\\Office2010Blue.DataVisualization.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); resw.WashColor = _washcolor; resw.WashMode = WinThemes.WashMode.HueSaturationReplacement; resw.AutoWash = true; resw.SourceDictionary = myResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(resw); myResourceDictionary.Source = new Uri("Themes\\Office2010Blue\\Office2010Blue.xamComboEditor.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); resw = new WinThemes.ResourceWasher(); resw.WashColor = _washcolor; resw.WashMode = WinThemes.WashMode.HueSaturationReplacement; resw.AutoWash = true; resw.SourceDictionary = myResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(resw); myResourceDictionary.Source = new Uri("Themes\\Office2010Blue\\Office2010Blue.xamDataPresenter.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); resw = new WinThemes.ResourceWasher(); resw.WashColor = _washcolor; resw.WashMode = WinThemes.WashMode.HueSaturationReplacement; resw.AutoWash = true; resw.SourceDictionary = myResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(resw); myResourceDictionary.Source = new Uri("Themes\\Office2010Blue\\Office2010Blue.xamDialogWindow.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); resw = new WinThemes.ResourceWasher(); resw.WashColor = _washcolor; resw.WashMode = WinThemes.WashMode.HueSaturationReplacement; resw.AutoWash = true; resw.SourceDictionary = myResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(resw); myResourceDictionary.Source = new Uri("Themes\\Office2010Blue\\Office2010Blue.xamEditors.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); resw = new WinThemes.ResourceWasher(); resw.WashColor = _washcolor; resw.WashMode = WinThemes.WashMode.HueSaturationReplacement; resw.AutoWash = true; resw.SourceDictionary = myResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(resw); myResourceDictionary.Source = new Uri("Themes\\Office2010Blue\\Office2010Blue.xamGauges.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); resw = new WinThemes.ResourceWasher(); resw.WashColor = _washcolor; resw.WashMode = WinThemes.WashMode.HueSaturationReplacement; resw.AutoWash = true; resw.SourceDictionary = myResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(resw); myResourceDictionary.Source = new Uri("Themes\\Office2010Blue\\Office2010Blue.xamMap.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); resw = new WinThemes.ResourceWasher(); resw.WashColor = _washcolor; resw.WashMode = WinThemes.WashMode.HueSaturationReplacement; resw.AutoWash = true; resw.SourceDictionary = myResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(resw); myResourceDictionary.Source = new Uri("Themes\\Office2010Blue\\Office2010Blue.xamMenu.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); resw = new WinThemes.ResourceWasher(); resw.WashColor = _washcolor; resw.WashMode = WinThemes.WashMode.HueSaturationReplacement; resw.AutoWash = true; resw.SourceDictionary = myResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(resw); myResourceDictionary.Source = new Uri("Themes\\Office2010Blue\\Office2010Blue.xamMultiColumnCombo.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); resw = new WinThemes.ResourceWasher(); resw.WashColor = _washcolor; resw.WashMode = WinThemes.WashMode.HueSaturationReplacement; resw.AutoWash = true; resw.SourceDictionary = myResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(resw); myResourceDictionary.Source = new Uri("Themes\\Office2010Blue\\Office2010Blue.xamRadialMenu.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); resw = new WinThemes.ResourceWasher(); resw.WashColor = _washcolor; resw.WashMode = WinThemes.WashMode.HueSaturationReplacement; resw.AutoWash = true; resw.SourceDictionary = myResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(resw); myResourceDictionary.Source = new Uri("Themes\\Office2010Blue\\Office2010Blue.xamSlider.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); resw = new WinThemes.ResourceWasher(); resw.WashColor = _washcolor; resw.WashMode = WinThemes.WashMode.HueSaturationReplacement; resw.AutoWash = true; resw.SourceDictionary = myResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(resw);
Looks like i got it working. I removed all these lines from the code:
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);