lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.01k stars 664 forks source link

When I click the Switch Theme button Twice,the theme Mica is not work #927

Open Smileher opened 5 months ago

Smileher commented 5 months ago

Describe the bug

When I click the Switch Theme button Twice,the theme Mica is not work

To Reproduce

Switch Dark Theme

Expected behavior

Mica

Screenshots

WeChat截图_20240202132206 WeChat截图_20240202132505 WeChat截图_20240202133049

OS version

Windows 11 23H2

.NET version

.NET FrameWork 4.8

WPF-UI NuGet version

3.0.0-preview.13

Additional context

No response

johnvesalius commented 4 months ago

Yeah, I see the same behaviour in 3.0.0. The Mica effect disappears when switching themes and is only applied again when the app is restarted.

Muniwedesu commented 1 month ago

By the way, it doesn't work because there was a fix for another issue (ig), which disabled setting background to transparent. To get this to work, you need to set your window background to transparent (there's a public method for this, it only needs your window reference) You can fix that like so:

{
    ApplicationThemeManager.Apply(appTheme == ApplicationTheme.Light
                    ? ApplicationTheme.Dark
                    : ApplicationTheme.Light);
                    // where 'this' is your window instance, 
                    // winver is client OS build number, but it doesn't seem to break anything 
                    // when you remove background on the earlier versions 
                    // 22621 is windows build number which has mica support, though it may also work fine on some earlier ones
                if (winver > 22621) WindowBackdrop.RemoveBackground(this); 
}
Jay-o-Way commented 4 weeks ago

Hey @lepoco, @pomianowski - You have a couple of issues regarding the Mica effect and theme switching. Might be a few duplicates, but would you be so kind to look into these issues? I see a lot of comments in different repositories about them. Thanks!

Smileher commented 4 weeks ago

By the way, it doesn't work because there was a fix for another issue (ig), which disabled setting background to transparent. To get this to work, you need to set your window background to transparent (there's a public method for this, it only needs your window reference) You can fix that like so:

{
    ApplicationThemeManager.Apply(appTheme == ApplicationTheme.Light
                    ? ApplicationTheme.Dark
                    : ApplicationTheme.Light);
                    // where 'this' is your window instance, 
                    // winver is client OS build number, but it doesn't seem to break anything 
                    // when you remove background on the earlier versions 
                    // 22621 is windows build number which has mica support, though it may also work fine on some earlier ones
                if (winver > 22621) WindowBackdrop.RemoveBackground(this); 
}

Thank you ,I solved the problem. if (Environment.OSVersion.Version.Build > 22621) WindowBackdrop.RemoveBackground(this);

Smileher commented 4 weeks ago

Hey @lepoco, @pomianowski - You have a couple of issues regarding the Mica effect and theme switching. Might be a few duplicates, but would you be so kind to look into these issues? I see a lot of comments in different repositories about them. Thanks!

Now that I have initially solved this problem, when I change the theme, I need to determine whether the windows system version number is greater than 22621, and when it is greater, I need to remove the background, as mentioned above in @Muniwedesu