@@ -554,6 +554,11 @@ public void RemoveDropShadowEffectFromCurrentTheme()
554554 ThemeHelper . CopyStyle ( windowBorderStyle , newWindowBorderStyle ) ;
555555
556556 // Copy Setters, excluding the Effect setter and updating the Margin setter
557+ // Only adjust margin if there's actually a shadow effect to remove,
558+ // preventing it from shrinking on repeated calls.
559+ bool hasEffect = windowBorderStyle . Setters . OfType < Setter > ( )
560+ . Any ( s => s . Property == UIElement . EffectProperty ) ;
561+
557562 foreach ( var setterBase in windowBorderStyle . Setters )
558563 {
559564 if ( setterBase is Setter setter )
@@ -562,7 +567,7 @@ public void RemoveDropShadowEffectFromCurrentTheme()
562567 if ( setter . Property == UIElement . EffectProperty ) continue ;
563568
564569 // Update Margin by subtracting the extra margin we added for the shadow
565- if ( setter . Property == FrameworkElement . MarginProperty )
570+ if ( hasEffect && setter . Property == FrameworkElement . MarginProperty )
566571 {
567572 var currentMargin = ( Thickness ) setter . Value ;
568573 var newMargin = new Thickness (
@@ -635,20 +640,8 @@ await Application.Current.Dispatcher.InvokeAsync(() =>
635640 // Get the actual backdrop type and drop shadow effect settings
636641 var ( backdropType , useDropShadowEffect ) = GetActualValue ( ) ;
637642
638- // Remove OS minimizing/maximizing animation
639- // Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3);
640-
641- // The timing of adding the shadow effect should vary depending on whether the theme is transparent.
642- if ( BlurEnabled )
643- {
644- AutoDropShadow ( useDropShadowEffect ) ;
645- }
646643 SetBlurForWindow ( _settings . Theme , backdropType ) ;
647-
648- if ( ! BlurEnabled )
649- {
650- AutoDropShadow ( useDropShadowEffect ) ;
651- }
644+ AutoDropShadow ( useDropShadowEffect ) ;
652645 } , DispatcherPriority . Render ) ;
653646 }
654647
@@ -725,39 +718,42 @@ private void SetBlurForWindow(string theme, BackdropTypes backdropType)
725718 // Apply the blur effect
726719 Win32Helper . DWMSetBackdropForWindow ( mainWindow , backdropType ) ;
727720 ColorizeWindow ( theme , backdropType ) ;
721+
722+ // DWM renders rounded corners for backdrop windows
723+ SetWindowCornerPreference ( "Round" ) ;
724+
725+ // Clear any stale directly-set WindowBorderStyle that might shadow
726+ // the merged dictionary entry we just modified above.
727+ if ( Application . Current . Resources . Contains ( "WindowBorderStyle" ) )
728+ Application . Current . Resources . Remove ( "WindowBorderStyle" ) ;
729+
730+ // For blur themes the resize border defaults to the system thickness.
731+ SetResizeBoarderThickness ( null ) ;
728732 }
729733 else
730734 {
731735 // Apply default style when Blur is disabled
732736 Win32Helper . DWMSetBackdropForWindow ( mainWindow , BackdropTypes . None ) ;
733737 ColorizeWindow ( theme , backdropType ) ;
738+
739+ // Non-blur themes use the default window corner preference
740+ SetWindowCornerPreference ( "Default" ) ;
734741 }
735742
736743 UpdateResourceDictionary ( dict ) ;
737744 }
738745
739746 private void AutoDropShadow ( bool useDropShadowEffect )
740747 {
748+ if ( BlurEnabled )
749+ return ; // Blur themes have no drop shadow effect
750+
741751 if ( useDropShadowEffect )
742752 {
743- if ( BlurEnabled && Win32Helper . IsBackdropSupported ( ) )
744- {
745- // For themes with blur enabled, the window border is rendered by the system,
746- // so we set corner preference to round and remove drop shadow effect to avoid rendering issues.
747- SetWindowCornerPreference ( "Round" ) ;
748- RemoveDropShadowEffectFromCurrentTheme ( ) ;
749- }
750- else
751- {
752- // For themes without blur, we set corner preference to default and add drop shadow effect.
753- SetWindowCornerPreference ( "Default" ) ;
754- AddDropShadowEffectToCurrentTheme ( ) ;
755- }
753+ AddDropShadowEffectToCurrentTheme ( ) ;
756754 }
757755 else
758756 {
759- // When drop shadow effect is disabled, we set corner preference to default and remove drop shadow effect.
760- SetWindowCornerPreference ( "Default" ) ;
761757 RemoveDropShadowEffectFromCurrentTheme ( ) ;
762758 }
763759 }
0 commit comments