Skip to content

Commit

Permalink
Set RequestedTheme immediately after InitializeComponent
Browse files Browse the repository at this point in the history
The `RequestedTheme` property is now set right after the `InitializeComponent()` call in the `App` class constructor, ensuring the application theme is applied immediately upon initialization.

The redundant setting of `RequestedTheme` in the `MainWindow` initialization has been removed, as it is no longer needed due to the earlier assignment in the constructor.

Signed-off-by: Christoph Hofmann <[email protected]>
  • Loading branch information
hoffe86 committed Jan 6, 2025
1 parent 7da623a commit 8c737de
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/openHAB.Windows/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ public partial class App : Application
/// <param name="logger">The logger instance.</param>
public App(IAppManager appManager, INotificationManager notificationManage, IOptions<SettingOptions> options, ILogger<App> logger)
{
InitializeComponent();
_options = options;
UnhandledException += App_UnhandledException;

DispatcherQueue = DispatcherQueue.GetForCurrentThread();

_logger = logger;
_appManager = appManager;
_notificationManager = notificationManage;

InitializeComponent();

RequestedTheme = _options.Value.AppTheme.ConvertToApplicationTheme();
UnhandledException += App_UnhandledException;
DispatcherQueue = DispatcherQueue.GetForCurrentThread();
}

/// <summary>
Expand Down Expand Up @@ -100,7 +101,6 @@ protected override async void OnLaunched(LaunchActivatedEventArgs e)
// Initialize MainWindow here
_mainWindow = Program.Host.Services.GetRequiredService<MainWindow>();

RequestedTheme = _options.Value.AppTheme.ConvertToApplicationTheme();
_appManager.SetAppTheme(MainWindow.Content);

MainWindow.Activate();
Expand Down

0 comments on commit 8c737de

Please sign in to comment.