FluentWPF icon indicating copy to clipboard operation
FluentWPF copied to clipboard

Fluent Design in Windows 11

Open sourcechord opened this issue 4 years ago • 11 comments

FluentWPF has some problems in Windows 11.

  • Acrylic Effect doesn't work properly.
  • MICA material haven't supported yet.
    • https://docs.microsoft.com/en-us/windows/apps/design/style/mica

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

sourcechord avatar Aug 11 '21 01:08 sourcechord

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 avatar Oct 15 '21 13:10 RickyYCheng

Facts: QQ截图20211015212410

without page

QQ截图20211015212423

with the page (attention title bar)

RickyYCheng avatar Oct 15 '21 13:10 RickyYCheng

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

poochie89 avatar Oct 18 '21 07:10 poochie89

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.

logue avatar Oct 27 '21 15:10 logue

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>

Simnico99 avatar Oct 29 '21 00:10 Simnico99

2021年10月15日(金) 22:12 Ricky @.***>:

Roll back to version 0.9 and everything work fine, included:

  1. Animation of maximization, normalization.
  2. Acrylic screen.
  3. DragMove.
  4. MinHeight and MinWidth Works well on Windows 11.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sourcechord/FluentWPF/issues/130#issuecomment-944286863, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRDPXHBYKLYFGRYDXUMWX3UHASCXANCNFSM5B5FJWLQ .

sourcechord avatar Oct 29 '21 10:10 sourcechord

same issue

NeverMorewd avatar Nov 17 '21 05:11 NeverMorewd

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

cfoucher avatar Dec 02 '21 00:12 cfoucher

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.

Searchstars avatar Dec 29 '21 05:12 Searchstars

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 :(

DimitarCC avatar Dec 29 '21 17:12 DimitarCC

@sourcechord can you update?

DeltaLaboratory avatar Feb 05 '22 18:02 DeltaLaboratory