diff --git a/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs b/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs index bccafdb30..2c7441484 100644 --- a/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs +++ b/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs @@ -103,7 +103,7 @@ static FluentWindow() protected override void OnSourceInitialized(EventArgs e) { OnCornerPreferenceChanged(default, WindowCornerPreference); - OnExtendsContentIntoTitleBarChanged(default, ExtendsContentIntoTitleBar); + OnExtendsContentIntoTitleBarChanged(false, ExtendsContentIntoTitleBar); OnBackdropTypeChanged(default, WindowBackdropType); base.OnSourceInitialized(e); @@ -182,10 +182,11 @@ protected virtual void OnBackdropTypeChanged(WindowBackdropType oldValue, Window return; } + SetWindowChrome(); + if (newValue == WindowBackdropType.None) { _ = WindowBackdrop.RemoveBackdrop(this); - return; } @@ -233,20 +234,26 @@ protected virtual void OnExtendsContentIntoTitleBarChanged(bool oldValue, bool n // AllowsTransparency = true; SetCurrentValue(WindowStyleProperty, WindowStyle.SingleBorderWindow); - WindowChrome.SetWindowChrome( - this, - new WindowChrome - { - CaptionHeight = 0, - CornerRadius = default, - GlassFrameThickness = new Thickness(-1), - ResizeBorderThickness = ResizeMode == ResizeMode.NoResize ? default : new Thickness(4), - UseAeroCaptionButtons = false, - } - ); - // WindowStyleProperty.OverrideMetadata(typeof(FluentWindow), new FrameworkPropertyMetadata(WindowStyle.SingleBorderWindow)); // AllowsTransparencyProperty.OverrideMetadata(typeof(FluentWindow), new FrameworkPropertyMetadata(false)); _ = UnsafeNativeMethods.RemoveWindowTitlebarContents(this); } + + /// + /// This virtual method is called when is changed. + /// + protected virtual void SetWindowChrome() + { + WindowChrome.SetWindowChrome( + this, + new WindowChrome + { + CaptionHeight = 0, + CornerRadius = default, + GlassFrameThickness = WindowBackdropType == WindowBackdropType.None ? new Thickness(0.00001) : new Thickness(-1), // 0.00001 so there's no glass frame drawn around the window, but the border is still drawn. + ResizeBorderThickness = ResizeMode == ResizeMode.NoResize ? default : new Thickness(4), + UseAeroCaptionButtons = false, + } + ); + } }