Skip to content

Instantly share code, notes, and snippets.

@riverar
Created July 8, 2015 19:53
Show Gist options
  • Save riverar/53c2d7293c15e1acc7d7 to your computer and use it in GitHub Desktop.
Save riverar/53c2d7293c15e1acc7d7 to your computer and use it in GitHub Desktop.
Contrived C#/WPF example implementing "Aero Glass" blur on Windows 10
internal void EnableBlur()
{
var windowHelper = new WindowInteropHelper(this);
var accent = new AccentPolicy();
var accentStructSize = Marshal.SizeOf(accent);
accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
Marshal.StructureToPtr(accent, accentPtr, false);
var data = new WindowCompositionAttributeData();
data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY;
data.SizeOfData = accentStructSize;
data.Data = accentPtr;
SetWindowCompositionAttribute(windowHelper.Handle, ref data);
Marshal.FreeHGlobal(accentPtr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment