private void doGlass()
{
//setHeight();
try
{
// Obtain the window handle for WPF application
IntPtr mainWindowPtr = new WindowInteropHelper(this).Handle;
HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
// Get System Dpi
System.Drawing.Graphics desktop = System.Drawing.Graphics.FromHwnd(mainWindowPtr);
float DesktopDpiX = desktop.DpiX;
float DesktopDpiY = desktop.DpiY;
// Set Margins
MARGINS margins = new MARGINS();
// Extend glass frame into client area
// Note that the default desktop Dpi is 96dpi. The margins are
// adjusted for the system Dpi.
margins.cxLeftWidth = -1;
margins.cxRightWidth = Convert.ToInt32(2 * (DesktopDpiX / 96));
margins.cyTopHeight = Convert.ToInt32(2 * (DesktopDpiX / 96));
margins.cyBottomHeight = -1;
int hr = DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);
WindowInteropHelper windowInteropHelper = new WindowInteropHelper(this);
IntPtr myHwnd = windowInteropHelper.Handle;
mainWindowSrc = System.Windows.Interop.HwndSource.FromHwnd(myHwnd);
mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
DWM_BLURBEHIND blurBehindParameters = new DWM_BLURBEHIND();
blurBehindParameters.dwFlags = DwmBlurBehindFlags.DWM_BB_ENABLE;
blurBehindParameters.fEnable = true;
blurBehindParameters.hRgnBlur = IntPtr.Zero;
DwmEnableBlurBehindWindow(myHwnd, ref blurBehindParameters);
}
// If not Vista or 7, paint background white.
catch (DllNotFoundException)
{
Application.Current.MainWindow.Background = Brushes.White;
}
}