<Window x:Class="Win11AcrylicFeature.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Title="Windows 11 Acrylic Demo" Height="450" Width="600" Background="Transparent" AllowsTransparency="True" WindowStyle="None"> <Grid> <Border x:Name="AcrylicBorder" Background="White" Opacity="0.85"> <Border.Background> <SolidColorBrush Color="#CCFFFFFF"/> </Border.Background> </Border> <StackPanel Margin="20"> <CheckBox x:Name="AcrylicToggle" Content="Enable Acrylic (Windows 11)" Checked="ToggleAcrylic" Unchecked="ToggleAcrylic"/> <TextBlock Text="This window uses dark mode title bar and optional acrylic blur." TextWrapping="Wrap" Margin="0,20"/> </StackPanel> </Grid> </Window>
<PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net8.0-windows10.0.17763.0</TargetFramework> <UseWPF>true</UseWPF> <UseWindowsForms>false</UseWindowsForms> <SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion> </PropertyGroup> Create a helper class Win11ThemeHelper.cs :
[DllImport("dwmapi.dll")] private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref bool value, int size);
private static bool IsSystemDarkMode() { try { using var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"); return key?.GetValue("AppsUseLightTheme") is int val && val == 0; } catch { return false; } } } MainWindow.xaml
private void ApplyAcrylicIfSupported() { if (IsWindows11OrNewer()) { var acrylicBrush = new SolidColorBrush(Color.FromArgb(180, 32, 32, 32)); AcrylicBorder.Background = acrylicBrush; // Real acrylic requires WinUI or custom composition – for demo we use semi-transparent. } }