Hi,
I'm trying to set a theme at runtime, but I see no changes in my UI. Here's what I'm trying.
switch ( theme ) { case 1: ThemeManager.CurrentTheme = ThemeManager.ThemeNameAero; break; case 2: ThemeManager.CurrentTheme = ThemeManager.ThemeNameLeaf; break; case 3: ThemeManager.CurrentTheme = ThemeManager.ThemeNameOnyx; break; case 4: ThemeManager.CurrentTheme = ThemeManager.ThemeNameOffice2k7Silver; break; default: throw new Exception(); }
But it doesn't seem to work. I've also tried getting the PrimativesXXX ResourceDictionary merged into the apps ResourceDictionary, but that doesn't work either.
The above code is in the App.xaml.cs.
Thanks
Andy
A similar approach could probably be acheived by putting resource dictionaries into the Application's Resources (and removing the last one whenever you change to a new one). You could get the resource dictionary for a given theme using the ThemeManager.GetResourceSet method passing in ThemeManager.AllGroupingsLiteral as the grouping name. That being said, you should be aware that there is a potential memory leak in the current WPF framework when you put RDs in the application resources.
Hi andrew,
We r now using infra controls in wpf application.here we need to change our using themes at run time.I mean
we pick a theme using drop down..previous application we done by app stylist run time infra controls.is any idea to do in wpf infragistics controls.
The themes that we have written are for our controls only at this point. We have not created/provided styles for the controls/elements that Microsoft ships as part of the WPF framework. You may want to submit a suggestion that we provide this as well.
Ok, the grids and dock manager use the themes, but basic wpf controls don't, and it doesn't look like much is done to igEditors either. Here's my new code. Am I doing something wrong?
switch ( theme ) { case 1: res = ThemeManager.GetResourceSet( ThemeManager.ThemeNameAero, ThemeManager.AllGroupingsLiteral ); break; case 2: res = ThemeManager.GetResourceSet( ThemeManager.ThemeNameLunaOlive, ThemeManager.AllGroupingsLiteral ); break; case 3: res = ThemeManager.GetResourceSet( ThemeManager.ThemeNameOffice2k7Silver, ThemeManager.AllGroupingsLiteral ); break; case 4: res = ThemeManager.GetResourceSet( ThemeManager.ThemeNameOnyx, ThemeManager.AllGroupingsLiteral ); break; default: throw new Exception(); }
Resources.MergedDictionaries.Add( res );
Ok... so if I want the Infragistics themes to apply to ALL controls, not just Infragistics controls, I should be putting the resources in the application resources, using the method you describe?