diff --git a/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs b/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs
index bef67db5a..2ee2f5428 100644
--- a/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs
+++ b/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs
@@ -88,13 +88,7 @@ public FluentWindow()
if (Utilities.IsOSWindows11OrNewer)
{
- ApplicationThemeManager.Changed += (_, _) =>
- {
- if (IsActive && ApplicationAccentColorManager.IsAccentColorOnTitleBarsEnabled)
- {
- UnsafeNativeMethods.ApplyBorderColor(this, ApplicationAccentColorManager.SystemAccent);
- }
- };
+ ApplicationThemeManager.Changed += OnApplicationThemeManagerChanged;
}
}
@@ -113,6 +107,21 @@ static FluentWindow()
);
}
+ private void OnApplicationThemeManagerChanged(ApplicationTheme currentApplicationTheme, Color systemAccent)
+ {
+ if (IsActive && ApplicationAccentColorManager.IsAccentColorOnTitleBarsEnabled)
+ {
+ UnsafeNativeMethods.ApplyBorderColor(this, ApplicationAccentColorManager.SystemAccent);
+ }
+ }
+
+ ///
+ protected override void OnClosed(EventArgs e)
+ {
+ ApplicationThemeManager.Changed -= OnApplicationThemeManagerChanged;
+ base.OnClosed(e);
+ }
+
///
protected override void OnSourceInitialized(EventArgs e)
{