private static void SetAccentPolicy(Window window, NativeMethods.AccentState accentState)
        {
            var windowHelper = new WindowInteropHelper(window);

            uint _blurOpacity         = (uint)0.75;
            uint _blurBackgroundColor = 0x990000;
            var  accent = new NativeMethods.AccentPolicy
            {
                AccentState   = accentState,
                AccentFlags   = GetAccentFlagsForTaskbarPosition(),
                GradientColor = (int)((_blurOpacity << 24) | (_blurBackgroundColor & 0xFFFFFF))
            };


            var accentStructSize = Marshal.SizeOf(accent);


            var accentPtr = Marshal.AllocHGlobal(accentStructSize);

            Marshal.StructureToPtr(accent, accentPtr, false);


            var data = new NativeMethods.WindowCompositionAttribData
            {
                Attribute  = NativeMethods.WindowCompositionAttribute.WCA_ACCENT_POLICY,
                SizeOfData = accentStructSize,
                Data       = accentPtr
            };

            NativeMethods.SetWindowCompositionAttribute(windowHelper.Handle, ref data);

            Marshal.FreeHGlobal(accentPtr);
        }
Example #2
0
        private static void SetAccentPolicy(Window window, NativeMethods.AccentState accentState)
        {
            var windowHelper = new WindowInteropHelper(window);


            var accent = new NativeMethods.AccentPolicy
            {
                AccentState = accentState,
                AccentFlags = GetAccentFlagsForTaskbarPosition()
            };


            var accentStructSize = Marshal.SizeOf(accent);


            var accentPtr = Marshal.AllocHGlobal(accentStructSize);

            Marshal.StructureToPtr(accent, accentPtr, false);


            var data = new NativeMethods.WindowCompositionAttribData
            {
                Attribute  = NativeMethods.WindowCompositionAttribute.WCA_ACCENT_POLICY,
                SizeOfData = accentStructSize,
                Data       = accentPtr
            };

            NativeMethods.SetWindowCompositionAttribute(windowHelper.Handle, ref data);

            Marshal.FreeHGlobal(accentPtr);
        }