Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
185
ThemeManager.CurrentTheme causing FrameworkElements to unload
posted

Hello,

I'm seeing an issue whereby when we set the theme in our application as follows:

ThemeManager

 

.CurrentTheme = theme;

where 'theme' is one of your preset themes - some of our controls seem to become unloaded. For example, combo boxes (both yours and standard WPF) would not show the popup (or popdown). When debugging I could see that the controls which were not responding have the property 'IsLoaded' set to false.

If the theme is set for the application, are you unloading controls in the background?

Thanks in advance.

 

 

Parents
No Data
Reply
  • 54937
    Offline posted

    We aren't directly loading or unloading elements. I have an article which in the background section discusses how theming works but basically when you set the Theme property, we put resources (Styles/Brushes/etc) into the ResourceDictionary where you have set the Theme. Since those styles have a Template setter, that will cause any element which picks up that local style to have its template changed. So in that case that element's descendants would be unloaded. I have seen some issues in the WPF framework where the IsLoaded property gets into a bad state because of some seemingly fragile code in IsLoaded which as part of its resolution considers whether objects are hooked into the loaded or unloaded events of it or its descendants as criteria for whether it is loaded or not. Do you have a simple project that demonstrates the problem you are seeing?

Children