public static bool ExtendGlassFrame(Window window, Thickness margin)
 {
     if (!DwmIsCompositionEnabled())
         return false;
     IntPtr hwnd = new WindowInteropHelper(window).Handle;
     if (hwnd == IntPtr.Zero)
         throw new InvalidOperationException(
         "The Window must be shown before extending glass.");
     // Устанавливаем прозрачный фон - как с точки зрения WPF, так и в Win32
     window.Background = Brushes.Transparent;
     HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor =
     Colors.Transparent;
     MARGINS margins = new MARGINS(margin);
     DwmExtendFrameIntoClientArea(hwnd, ref margins);
     return true;
 }
 static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);