/// <summary> /// Uses DwmApi to render the entire window in Aero glass /// </summary> void InitializeGlass() { var bb = new DwmApi.DwmBlurbehind { dwFlags = (int)DwmApi.DwmBlurBehindDwFlags.DwmBbEnable, fEnable = true }; Background = Brushes.Transparent; ResizeMode = ResizeMode.NoResize; WindowStyle = WindowStyle.None; var hwnd = new WindowInteropHelper(this).Handle; var hwndSource = HwndSource.FromHwnd(hwnd); if (hwndSource != null) { if (hwndSource.CompositionTarget != null) { hwndSource.CompositionTarget.BackgroundColor = Colors.Transparent; } } DwmApi.DwmEnableBlurBehindWindow(hwnd, ref bb); var dwmncrpDisabled = 2; DwmApi.DwmSetWindowAttribute(hwnd, DwmApi.DwmWindowAttribute.DWMWA_NCRENDERING_POLICY, ref dwmncrpDisabled, sizeof(int)); Topmost = true; Focus(); }
/// <summary> /// Uses DwmApi to render the entire window in Aero glass /// </summary> void InitializeGlass() { var bb = new DwmApi.DwmBlurbehind { dwFlags = (int)DwmApi.DwmBlurBehindDwFlags.DwmBbEnable, fEnable = true }; Background = Brushes.Transparent; ResizeMode = ResizeMode.NoResize; WindowStyle = WindowStyle.None; var hwnd = new WindowInteropHelper( this ).Handle; var hwndSource = HwndSource.FromHwnd( hwnd ); if ( hwndSource != null ) if ( hwndSource.CompositionTarget != null ) hwndSource.CompositionTarget.BackgroundColor = Colors.Transparent; DwmApi.DwmEnableBlurBehindWindow( hwnd, ref bb ); var dwmncrpDisabled = 2; DwmApi.DwmSetWindowAttribute( hwnd, DwmApi.DwmWindowAttribute.DWMWA_NCRENDERING_POLICY, ref dwmncrpDisabled, sizeof( int ) ); Topmost = true; Focus(); }