/// <summary>Extends the frame into client area. /// </summary> /// <param name="hwnd">The Window.</param> /// <param name="margin">The margin.</param> /// <returns><c>True</c> if the function succeeded, <c>False</c> otherwise.</returns> public static void ExtendFrameIntoClientArea(IntPtr hwnd, Thickness margin) { if (!IsCompositionEnabled) throw new InvalidOperationException("Composition is not enabled. Glass cannot be extended."); if (hwnd == IntPtr.Zero) throw new InvalidOperationException("The Window must be shown before extending glass. As a suggestion, in WPF you should call this during the SourceInitialized event."); // Set the background to transparent to get the full Glass effect HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent; MARGINS margins = new MARGINS(margin); DwmExtendFrameIntoClientArea(hwnd, ref margins); }
private static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS margins);