public static void EnableBlur(Window window) { var windowHelper = new WindowInteropHelper(window); var accent = new AccentPolicy(); accent.AccentState = AccentState.ACCENT_ENABLED_BLURBEHIND; var accentStructSize = Marshal.SizeOf(accent); var accentptr = Marshal.AllocHGlobal(accentStructSize); Marshal.StructureToPtr(accent, accentptr, false); var data = new WindowsCompositionAttributeData(); data.Attribute = WindowsCompositionAttribute.WCA_ACCENT_POLICY; data.SizeOfData = accentStructSize; data.Data = accentptr; SetWindowCompositionAttribute(windowHelper.Handle, ref data); Marshal.FreeHGlobal(accentptr); }
internal static extern int SetWindowCompositionAttribute(IntPtr hand, ref WindowsCompositionAttributeData data);