Fluent Design in Windows 11
sourcechord opened this issue · 11 comments
FluentWPF has some problems in Windows 11.
- Acrylic Effect doesn't work properly.
- MICA material haven't supported yet.
Please comment in this issue about Fluent Design in Windows 11.
Rollback to version 0.9 and everything work fine, included:
- Animation of the maximized window to normal window.
- Animation of the normal window to maximized window.
- Animation of the minimized window to maximized / normal window.
- Animation of the maximized / normal window to minimized window.
- Acrylic screen.
- DragMove.
- MinHeight and MinWidth
Works well on Windows 11.
Does ACRYLICBLURBEHIND not work at all on Windows 11?
Any way to fix this?
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.
Actually found an easy way to apply Mica to a window in WPF:
PS it also supports snap grids:
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>
same issue
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
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.
@sourcechord can you update?