private void SetGlass() { IsCompositionEnabled = DesktopWindowManager.IsCompositionEnabled; if (ParentWindow != null) { if (IsCompositionEnabled) { orinalWindowBackground = ParentWindow.Background; ParentWindow.Background = Brushes.Transparent; HwndSource.CompositionTarget.BackgroundColor = Colors.Transparent; Matrix dpiMatrix = HwndSource.CompositionTarget.TransformToDevice; double dpiY = dpiMatrix.M22; // Create a margin structure var margins = new WinApi.Margins { Left = 0, Right = 0, Top = (int)Math.Round(this.ActualHeight * dpiY, MidpointRounding.AwayFromZero), Bottom = 0 }; DesktopWindowManager.ExtendFrameIntoClientArea(HwndSource.Handle, ref margins); } DesktopWindowManager.SetTitleAndIconVisibility(HwndSource.Handle, false); } }
private void ResetGlass() { if (ParentWindow != null) { if (IsCompositionEnabled) { ParentWindow.Background = orinalWindowBackground; DesktopWindowManager.ResetGlass(HwndSource.Handle); } DesktopWindowManager.SetTitleAndIconVisibility(HwndSource.Handle, true); } }