Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluent Design in Windows 11 #130

Open
sourcechord opened this issue Aug 11, 2021 · 11 comments
Open

Fluent Design in Windows 11 #130

sourcechord opened this issue Aug 11, 2021 · 11 comments

Comments

@sourcechord
Copy link
Owner

FluentWPF has some problems in Windows 11.

Please comment in this issue about Fluent Design in Windows 11.

@RickyYCheng
Copy link

RickyYCheng commented Oct 15, 2021

Rollback to version 0.9 and everything work fine, included:

  1. Animation of the maximized window to normal window.
  2. Animation of the normal window to maximized window.
  3. Animation of the minimized window to maximized / normal window.
  4. Animation of the maximized / normal window to minimized window.
  5. Acrylic screen.
  6. DragMove.
  7. MinHeight and MinWidth

Works well on Windows 11.

@RickyYCheng
Copy link

RickyYCheng commented Oct 15, 2021

Facts:
QQ截图20211015212410

without page

QQ截图20211015212423

with the page (attention title bar)

@poochie89
Copy link

Does ACRYLICBLURBEHIND not work at all on Windows 11?
Any way to fix this?

@logue
Copy link

logue commented Oct 27, 2021

When using Fluent Wpf with MahApps, there was a lag when moving the semi-transparent window, but when using Fluent WPF with Modern WPF, it worked without any problems.

@Simnico99
Copy link

Actually found an easy way to apply Mica to a window in WPF:
image
PS it also supports snap grids:
image

public enum WindowsTheme
{
	Light,
	Dark
}

public class ThemeHelper
{
	private const string _registryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";

	private const string _registryValueName = "AppsUseLightTheme";


	public static WindowsTheme GetWindowsTheme()
	{

        using RegistryKey? key = Registry.CurrentUser.OpenSubKey(_registryKeyPath);
        object? registryValueObject = key?.GetValue(_registryValueName);
        if (registryValueObject == null)
        {
            return WindowsTheme.Light;
        }

        int registryValue = (int)registryValueObject;

        return registryValue > 0 ? WindowsTheme.Light : WindowsTheme.Dark;
    }
}

public static class MicaHelper
{
    [DllImport("dwmapi.dll")]
    private static extern int DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, ref int pvAttribute, int cbAttribute);

    [Flags]
    private enum DwmWindowAttribute : uint
    {
        DWMWA_USE_IMMERSIVE_DARK_MODE = 20,
        DWMWA_MICA_EFFECT = 1029
    }

    public static void UpdateStyleAttributes(this Window window)
    {
        IntPtr windowHandle = new WindowInteropHelper(window).Handle;
        var darkThemeEnabled = ThemeHelper.GetWindowsTheme();

        int trueValue = 0x01;
        int falseValue = 0x00;

        if (darkThemeEnabled == WindowsTheme.Dark)
        {
            _ = DwmSetWindowAttribute(windowHandle, DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE, ref trueValue, Marshal.SizeOf(typeof(int)));
        }
        else
        {
            _ = DwmSetWindowAttribute(windowHandle, DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE, ref falseValue, Marshal.SizeOf(typeof(int)));
        }

        _ = DwmSetWindowAttribute(windowHandle, DwmWindowAttribute.DWMWA_MICA_EFFECT, ref trueValue, Marshal.SizeOf(typeof(int)));
    }
}

Usage:
Window code behind:

    public MainWindow()
    {
        this.UpdateStyleAttributes();
    }

Window Xaml:

<Window x:Class="WpfTest01.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfTest01"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800"
        Background="Transparent">
    <WindowChrome.WindowChrome>
        <WindowChrome
            CaptionHeight="20"
            ResizeBorderThickness="8"
            CornerRadius="0"
            GlassFrameThickness="-1"
            UseAeroCaptionButtons="True" />
    </WindowChrome.WindowChrome>
    <Grid>

    </Grid>
</Window>

@sourcechord
Copy link
Owner Author

sourcechord commented Oct 29, 2021 via email

@NeverMorewd
Copy link

same issue

@cfoucher
Copy link

cfoucher commented Dec 2, 2021

I was able to get an ACRYLICBLURBEHIND working under Windows 11 by not setting accent.AccentFlags = 2 and by setting the WindowStyle="None" along with fw:AcrylicWindow.AllowsTransparency="True". Here is a branch with a modified sample app with the working Acrylic window: https://github.com/cfoucher/FluentWPF/tree/win11_acrylicBlur

image

@Searchstars
Copy link

Roll back to version 0.9, and acrylic effect can work normally. However, there are some problems, such as dragging the window slowly and window flashing when dragging the window.

@DimitarCC
Copy link

DimitarCC commented Dec 29, 2021

ACRYLICBLURBEHIND is working just fine on Windows 11. I was able to make acrylic menu/popup with it.

image

The only disadvantage is that there are no fancy slide animations on popup opening. They just do not work :(

@DeltaLaboratory
Copy link

@sourcechord can you update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants