We are having an important issue trying to use the ThemeManager. I have asked long ago how to set the Current Theme on the Ribbon and other controls here.
Everything was working fine until we updated to Infragistics 2015.1 (without the service packs).
When we set the theme in the ThemeManager like this:
ThemeManager.CurrentTheme = "Onyx";
Nothing happens! Are we doing something wrong?
Thanks!
PS: I added a post to my old question, but I don't know if anyone is following it up.
PS2: Is there a Code Format option? I don't see it. It would be useful to have one.
Hi Dzyann,
Sorry for not seeing your other forum thread. In 14.2 we added a new ThemeManager component that resides in the Infragistics.Themes namespace. The old theme stuff should not have been affected as it resides in a different namespace (Infragistics.Windows.Themes) and it is a separate component. I created a small test app with a ribbon and I set the CurrentTheme to "Onyx" and the ribbon's Theme property to "[current]" and this still applied the Onyx theme. I'm not really sure why it's not working for you. Do you have a sample that you could send me that reproduces the issue you see so I can debug it?
Hi Rob,
Thanks for your answer, I had some issues and I couldn't answer before.
I have updated the solution you provided so you can see how it fails.
I have added:
ThemeManager.CurrentTheme = ThemeManager.ThemeNameIGTheme;
To the application startup, you will see it doesn't have any effect.
I also added some buttons to the ribbon to switch between themes on the fly, none of them work. The property gets set but nothing happens.
Now not even the code where you set the theme as Onyx seems to work.
Please let me know what do you think we are doing wrong.
Thank you!
I missed that part in parenthesis, I should have realized. 15.1.1000 is the base version. As for the source of this error, I'm not sure. I checked our bug history and there were a couple for the ThemeManager where themes weren't being applied to controls but I think these were for the new ThemeManager, not the old one. Maybe there is some overlap in the code they use. Not sure.
Since the base version, we have had two service updates making the current version 15.1.2055. I tested the first update that exists (15.1.2008) and this issue stopped occurring. The themes applied like you would expect. I want to point out that the first update was released the same day that 15.1 was released so it's likely that our internal tests picked up on this issue and it was resolved internally without a bug being created for it (which is why I wouldn't be able to find it). It was probably discovered too late to make the base version (15.1.1000) so it was included in the update (15.1.2008).
It seems to be working, however I've noticed like it doesn't seem to work for all the Theme.s For example the Luna ones, when I try to apply them, they all look like the standard Infragistics (bluish) one.
Is that ok? Or do I have something not configured properly?
Also, I would like to validate something with you. Our users want to override the styles, only for certain controls, but by providing only the Styles.
How could I make use of them? Would it be valid to do something like this (following from your answers to my other question):
string[] groupings = ThemeManager.GetGroupingsForTheme(ThemeManager.CurrentTheme); foreach (string group in groupings) ThemeManager.Register(ThemeManager.CurrentTheme, group, dictionary);
Basically they don't want to set the Theme, so I register their styles in the CurrentTheme. Would this work ok?
Is my understanding that Infragistics Themes, have Themes for all the controls, when I do this, what happens to the default infragistics styles? Are they overriden?
For example in the CurrentTheme there are styles for the DockManager and I am Registering a new style for it, will it work? Is this the correct way to go about this issue?
This is expected. The Luna themes are not used by the ribbon.
As for registering a resource dictionary with your style changes, registering does in fact override the built in theme dictionaries. So if your users want to provide their own styles while still using the built in theme they will have to provide those styles to the control's Resources collection. They have to be placed in the control's Resources collection because this causes them to have a higher priority than the styles provided by the theme. If they are too high up in the visual tree then they will not be used.
Another option would be to include all of the theme ResourceDictionaries that we provide with the product in the installation directory, add your custom style to this resource dictionary and then register this updated dictionary with the ThemeManager. This would require adding a lot of xaml to your project, however.
So, let me see if I understand correctly, you don't advice we Register Resource Dictionaries with the ThemeManager but to instead add to, for example, the DockManager Resources Collection the Styles that override the styles of the default theme for the DockManager?
Correct. I checked the source code for the old ThemeManager and when you call Register() it grabs the object that is holding onto the existing ResourceDictionary and it just replaces it with the new one you passed into Register.
Your DockManager example is the simplest way to deal with this. Take your styles that you want to override the theme ones with and add them to the DockManager's Resources collection. This will place those styles closer to the control in the Visual Tree so it will use those styles rather than the theme ones. The other option would be to create a ResourceDictionary that references the existing theme files we provide and then register that ResourceDictionary. As I stated previously this will require adding a lot of XAML to your project as you would need to do this for every control you wish to override styles for. The existing theme files can be found here: C:\Program Files (x86)\Infragistics\2015.1\WPF\DefaultStyles
It's worth noting that the answers in this thread are obsolete. The ThemeManager no longer provides access to theme mappings.
Thanks for your help! We will analyze your suggestions.
The update to the latest Infragistics version solved the original issue.