We have recently implemented DI for our WPF app, and in doing so it appears the theming no longer works. Our main form is a XamRibbonWindow, and we are now instantiating it using injection to satisfy its dependencies. Everything works except the theming. We are using the ThemeManager to set the ApplicationTheme in startup, however no theme is applied when the window is resolved from our IoC container (ninject at the moment).
Of note, if we decorate the RibbonWindowContentHost with Theme="[current]", the ribbon does get themed, but the rest of its controls do not. More interestingly, if we decorate the XamDataGrid contained witihin, with Theme="[current]", it displays black headers seemingly from another theme.
Upon inspection of the created XamRibbonWindow, the IsOffice2013 flag is false. Is there something about injecting the views that is causing this behavior? If so, is there an alternative way to get the application wide theming working in this context?
ThemeManager.ApplicationTheme= new Office2013Theme();
I have some more findings to add. It does appear that theming is being picked up to some degree, as I have switched between metrodark and IG themes and can see changes. It appears as if the Office2013 theme in 2020.2 is corrupt. Another interesting finding is that the XamRibbonWindow menu doesn't appear to pick up the theme no matter what from the ThemeManager. Note the 2 attachements. Working in 17.2 with the office2013 theme. Not working in 20.2 with the office 2013 theme.
Not working. Note the menu not showing properly, and no styling applied.
Any help appreciated.
Hello Chris,
I have been investigating into the behaviors you are reporting, and at the moment, I am unable to see the “[current]” setting working for the Theme property in either 2017.2 or 2020.2. With that said though, this should not be necessary if you are setting the ApplicationTheme, as this should be applying the theme in everything in the Application’s scope.
If this is not the case after removal of the “[current]” Theme setting, please let me know, as this might be something more specific to your application such as other styling at a lower scope that is not based on the Office2013 theme, but I cannot seem to see this “[current]” functionality working with the XamRibbon, although at the moment I am unsure if this *should* work, as I don’t really see it documented anywhere on our end.
Please let me know if you have any other questions or concerns on this matter.
I believe there was some confusion on the theme examples. In the original version of the code, it appeared that the theme Office2013 was employed and presenting with the blue background, which was the desired theme. After the injection changes, I believe that the theme was actually being applied and that is the white background seen in the screenshot above. After setting the theme to null, the desired theme returned, so developer error it seems. I am still unsure about why explicitly setting the theme on each element to "[current]" presented the blue theme, while the theme manager was set to Office2013, which appears to be the white palette.