From e9838141767577db4fe2cabe73eff31cdc70d224 Mon Sep 17 00:00:00 2001 From: Bugadinho <31747009+Bugadinho@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:54:32 -0300 Subject: [PATCH] ColorValuesChanged now reapplies the theme --- Bloxstrap/UI/Elements/Base/WpfUiWindow.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs b/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs index db06e7f..ccc7181 100644 --- a/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs +++ b/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs @@ -4,23 +4,27 @@ using Wpf.Ui.Appearance; using Wpf.Ui.Controls; using Wpf.Ui.Mvvm.Contracts; using Wpf.Ui.Mvvm.Services; +using Windows.UI.ViewManagement; namespace Bloxstrap.UI.Elements.Base { public abstract class WpfUiWindow : UiWindow { private readonly IThemeService _themeService = new ThemeService(); + private UISettings _settings; public WpfUiWindow() { ApplyTheme(); + _settings = new UISettings(); + _settings.ColorValuesChanged += ColorValuesChanged; } public void ApplyTheme() { _themeService.SetTheme(App.Settings.Prop.Theme.GetFinal() == Enums.Theme.Dark ? ThemeType.Dark : ThemeType.Light); _themeService.SetSystemAccent(); - + #if QA_BUILD this.BorderBrush = System.Windows.Media.Brushes.Red; this.BorderThickness = new Thickness(4); @@ -37,5 +41,13 @@ namespace Bloxstrap.UI.Elements.Base base.OnSourceInitialized(e); } + + private async void ColorValuesChanged(UISettings sender, object args) + { + await Dispatcher.InvokeAsync(() => + { + ApplyTheme(); + }); + } } }