wpfui
wpfui copied to clipboard
When I click the Switch Theme button Twice,the theme Mica is not work
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
OS version
Windows 11 23H2
.NET version
.NET FrameWork 4.8
WPF-UI NuGet version
3.0.0-preview.13
Additional context
No response
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.
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);
}
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!
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);
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