private void UpdateGlassEffects() { if (this.dwmHelper != null) { if (this.GlassMargin != null) { GlassMargin GlassMargin = this.GlassMargin; this.dwmHelper.Margins = new DwmApi.Margins( (int)GlassMargin.Left, (int)GlassMargin.Right, (int)GlassMargin.Top, (int)GlassMargin.Bottom); } else { this.dwmHelper.Margins = new DwmApi.Margins(0); } this.dwmHelper.BlurClientArea = this.BlurClientArea; if (this.dwmHelper.DwmIsCompositionEnabled) { HwndSource.FromHwnd(this.dwmHelper.WindowHandle).DbC_AssureNotNull().CompositionTarget.DbC_AssureNotNull().BackgroundColor = Colors.Transparent; } else { HwndSource.FromHwnd(this.dwmHelper.WindowHandle).DbC_AssureNotNull().CompositionTarget.DbC_AssureNotNull().BackgroundColor = this.AllowsTransparency ? Colors.Transparent : SystemColors.WindowColor; } this.EnsureBorderlessNonresizableWindowShowsGlassBackground(); this.SetValue(Window.isDwmEnabledPropertyKey, this.dwmHelper.DwmIsCompositionEnabled); } else { //ignore - before completely initialized } }
private void NotifyGlassMarginChanged(GlassMargin oldValue, GlassMargin newValue) { if (oldValue != null) { oldValue.PropertyChanged -= this.GlassMarginPropertyChanged; } if (newValue != null) { newValue.PropertyChanged += this.GlassMarginPropertyChanged; } this.UpdateGlassEffects(); }