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.38k stars 715 forks source link

Switching theme loses transparency #1163

Open Apskalle opened 1 month ago

Apskalle commented 1 month ago

Describe the bug

When switching light to dark (or other way around) mica or acrylic transparency is lost.

To Reproduce

Can be tried on simple demo (https://github.com/lepoco/wpfui/tree/main/src/Wpf.Ui.Demo.Simple/)

Expected behavior

Theme should remain transparent

Screenshots

Before_after

OS version

Windows 11 Pro Version 23H2 OS-version 22631.3880 Windows Feature Experience Pack 1000.22700.1020.0

.NET version

net 8.0, SDK 9 preview

WPF-UI NuGet version

3.0.4

Additional context

No response

tonyrichter commented 1 month ago

Ah that's what I was noticing. I did notice a slight color change but wasn't really sure about it because I used TeamViewer and colors are strange there anyway.

Can confirm!

duyle1402 commented 4 weeks ago

I facing same problem when using latest version 3.0.5.

Apskalle commented 4 weeks ago

Update: Backdrop changing works fine if you instead of using ApplicationThemeManager.Apply() bind the windows WindowBackdropType property (change notification needed)

<ui:FluentWindow x:Class="Core.Login"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        ...
          xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
          WindowBackdropType="{Binding MyThemeManager.SelectedTheme.WindowBackdropType}"
          ExtendsContentIntoTitleBar="True">
yuyoyuppe commented 3 weeks ago

My MainWindow must preserve transparency, and I use tray:NotifyIcon without ui:FluentWindow, thus I don't need backdrop functinonality. However, to facilitate tray menu reacting to theme changes, I've had to use the following code to workaround the issue with this code:

private void UpdateWPFUITheme(bool darkMode) {
    ApplicationTheme theme = darkMode ? ApplicationTheme.Dark : ApplicationTheme.Light;
    Window? mainWindow = UiApplication.Current.MainWindow;
    UiApplication.Current.MainWindow = null;
    ApplicationThemeManager.Apply(theme, Wpf.Ui.Controls.WindowBackdropType.None, false);
    UiApplication.Current.MainWindow = mainWindow;
}