AvaloniaUI/Avalonia

AcrylicBlur does not work on Windows11 10.0.22631

NeverMorewd opened this issue · 1 comments

Describe the bug

Windows 11 professional edition
10.0.22631 build 22631

screenshot:
image

To Reproduce

code:
AcrylicBlurIssueWin11.zip

Expected behavior

No response

Avalonia version

11.2.2

OS

Windows

Additional context

The issue likely isn't specific to Avaloniaui, as I've encountered a similar problem in my WPF application.
Here is my code about AcrylicBlur in wpf.

var accent = new AccentPolicy
{
    AccentState = AccentState.ACCENT_ENABLE_ACRYLICBLURBEHIND,
    GradientColor = _blurColor
};
var accentPolicySize = Marshal.SizeOf(accent);
var accentPtr = Marshal.AllocHGlobal(accentPolicySize);
Marshal.StructureToPtr(accent, accentPtr, false);
try
{
    var data = new WindowCompositionAttributeData
    {
        Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
        SizeOfData = accentPolicySize,
        Data = accentPtr,
    };
    SetWindowCompositionAttribute(handle, ref data);
}
finally
{
    Marshal.FreeHGlobal(accentPtr);
}