Closed kacciocciacciara closed 3 years ago
Hi @kacciocciacciara are you able to share more information about your code. I am not currently able to replicate the issue.
Can you confirm that you are seeing the Settings.Interface.UseDarkTheme
change from true to false?
Yes, I can confirm. It's the first thing I thought it could be the cause, but the boolean value updates correctly. There aren't any errors nor exceptions, it looked like the SetTheme method did nothing.
@kacciocciacciara are you able to share the project? I am not able to replicate the issue.
Hi @Keboo unfortunately, I can't. It's a project I'm working for my company and I can't share any source. I'm inclined to think that the issue is within my code and not in the toolkit itself. Next week I'll make a quick project with the toolkit's latest version and I'll give you a feedback ASAP. Thank you for your time.
Hi @Keboo I made the test project with the same logic of my actual project. I confirm that this solution works with 4.1.0 but doesn't with 4.2.1. Please let me know if I did a mistake using the package. Thank you DemoMaterialDesignXAML.zip .
Hi @kacciocciacciara thank you for the example. That is very helpful. There was some performance caching that was introduced in 4.2.1 that fixed a different bug which is the reason for the behavior you are now seeing. The issue you are running into is because you are setting the color theme resources twice in your App.xaml. Specifically this:
<materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="Blue" SecondaryColor="Green" ColorAdjustment="{materialDesign:ColorAdjustment}"/>
And this:
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Green.xaml" />
Both set the color theme resources. I recommend that you only use one of them (my preference is the first one). Only having one of those in the App.xaml will resolve the issue you are seeing.
Hi @Keboo I tried your solution and it works like intended. The only "problem" now is that accessing resources like PrimaryHueMidBrush is difficult because I need to remember the exact name without the help of XAML IntelliSense. If you have a suggestion about this, I'm all ears. Thank you very much for your assistance.
@kacciocciacciara Unforuently right now you sort of have to decide between the XAML intellisense of the second option I posted, and the convenience of the BundledTheme. That is something that is working on being addressed in the 4.3.0 release as part of #2435
@Keboo I read the issue about the color naming. Very interesting, and I feel like it's better than the actual system. I'll close this issue, you answered all I needed to know. Thank you again!
I have the following snippet of code that updates my base theme:
version 4.1.0 - working update to 4.2.1 - not working rollback to 4.1.0 - working
In the new version, my application starts with the light theme and never updates to dark.