How can i apply a style to, for example, a button, when using the new ThemeManager to theme MS WPF controls? If I apply any style, the IG theme is disregarded? See the sample app. It shows a button with an explicit style that just sets its width and height. But when i apply it to my button, the button no longer takes the properties from the ThemeManager. I tried BasedOn, it didn't help. Also, Implicit styling of a button seems to be ignored (commented out in my sample as to show No Style). Is there a way to accomplish styling the button based of the IG Theme?
Hi Travis,
Your BasedOn style actually does work but because of the order in which things are added to the Application.Resources, the ThemeManager resource dictionary is getting priority over the based on Button style. The first dictionary added to the Application.Resources.MergedDictionaries collection is your explicit styles one. After which the IG Theme resource dictionary is added. Since it was added second, it's resources have priority.
If you move your resource dictionary into the MainWindow.Resources you'll see that your BasedOn style works. So in order for your custom styles to be used, they need to basically be added after the ThemeManager's resources.
Given that i use this button theme throughout my application (many windows etc), is there a way i can delay or otherwise get the style to be applied in a way that will allow it to work other than placing it in EVERY window's resources? Thanks
My bad. Really sorry!
I was testing against a build with the async fix disabled and fooled myself.
The solution I provided doesn't work for the same reason Rob's suggestion does not.
At this point the only solution I found is referencing the resources by using DynamicResource instead of StaticResource.
Another thing is that you need to base your style on the keyed resource for the button style of the theme - you could find the RC that is applying the implicit styles looking at the bottom of C:\Program Files (x86)\Infragistics\2014.2\WPF\Themes\Metro\Metro.MSControls.Core.Implicit.xaml. This dictionary is what the TM is loading if StyleMicrosoftControls is true (the default value).
I've attached modified sample using DynamicResource and the custom styles are based on {StaticResource ButtonStyle}.
Sorry once again for the confusion and hope this one do work for you.
Forgot to mention that forcing you to use DynamicResource is not ok and I'll spend some more time trying to find a better solution.
any solution yet?
Sorry for the late response.
The alternative on using DynamicResource is to manually add RCs from the theme containing the styles you need to extend to your application resources. This way you don't need to subclass the theme class. Using this approach you could also base your extended styles on the implicit ones from the theme - i.e. BasedOn="{StaticResource {x:Type Button}}".
Check out the attached sample solution.
Hope this helps,
I've been wandering did you manage to check out my last suggestion and is it working for you.
I'll be glad to help further if needed.
Thanks,
Hello Travis,
Thank you for your reply and the feedback on this issue. I have been further investigating and currently, the approach I have suggested in my previous reply seems to be the best in the scenario that you are having.
We are continuously working on improving the quality of the controls and your feedback is valuable in this process. If you have any suggestions on what we can change in Themes/TheamManager to make it more easy to use and better for you, it would be great to share your thoughts on that matter. You can do that here in the forums or you can also create a support ticket through our website or submit a new Product Idea for something that you think it will help improving our products.
If I can assist you with anything else, please do not hesitate to ask.
i've simply given up on infragistics themes, there always another problem. not worth the time...