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?
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.
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.
Thanks for your response. Unfortunately, the sample you provided does not run.
'Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '16' and line position '38'.
The Styles for Style1 and Style2 buttons are not found...
Hi Travis,
Thanks a lot for your interest in ThemeManager.
Actually what Rob suggested works except in the latest Service Release - WPF.Nightly_14.2.20142.2081 :) That is so because of the fix for the issue you reported with your previous thread where it was throwing an exception when having plain XamDataGrid. In order to fix it we had to do the loading of the xaml resources asynchronously. So what is happening in your sample when your custom styles get parsed the ThemeManager hasn't loaded the RD(ResourceDictionary) containing the implicit styles yet.
I wouldn't recommend applying a theme to a specific part of the VisualTree(like MainWidnow) because of a limitation of WPF documented here. Basically some dialogs(popups) used by some controls does not get affected of the styles when they are not applied on Application level.
I've attached a sample solution that should be working well for you. In a nutshell we're creating new RD and instructing the TM to to load that new RD instead of the one it is loading by default. In order not to loose the styles containing the implicit styles we need to merge it to the RD we created. Here's a doc article explaining the process of creation of a custom theme.
I hope this would work well for you. If you need any other assistance with this please don't hesitate to ask.
After moving the resource dictionary into MainWindow, the IG theme still doesn't appear to be applied. Notice the first two buttons still don't have the IG theme applied (they are not square, etc. like the 3rd button). Maybe i misunderstood your comments, but moving the ResourceDictionary doesn't seem to have any affect for me. Included modified sample. If this works for you, please modify the sample to show me exactly how you did it.