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!
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
Thanks for your help! We will analyze your suggestions.
The update to the latest Infragistics version solved the original issue.
It's worth noting that the answers in this thread are obsolete. The ThemeManager no longer provides access to theme mappings.