From c0443375393f7982be03ed6bdf88c7db80547dd1 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 19 Jan 2026 19:59:34 -0500 Subject: [PATCH] feat(configmanager): complete service registrations in App.axaml.cs Add IDialogService registration using factory pattern for window access. Add GetMainWindow helper method to provide window reference for dialogs. --- .../JdeScoping.ConfigManager/App.axaml.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/NEW/src/Utils/JdeScoping.ConfigManager/App.axaml.cs b/NEW/src/Utils/JdeScoping.ConfigManager/App.axaml.cs index 6ea16f7..1904922 100644 --- a/NEW/src/Utils/JdeScoping.ConfigManager/App.axaml.cs +++ b/NEW/src/Utils/JdeScoping.ConfigManager/App.axaml.cs @@ -1,4 +1,5 @@ using Avalonia; +using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; using JdeScoping.ConfigManager.Services; @@ -15,17 +16,13 @@ public partial class App : Application /// public static IServiceProvider Services { get; private set; } = null!; - /// - /// Initializes the Avalonia XAML loader. - /// + /// public override void Initialize() { AvaloniaXamlLoader.Load(this); } - /// - /// Called when the framework initialization is complete; configures services and sets the main window. - /// + /// public override void OnFrameworkInitializationCompleted() { var services = new ServiceCollection(); @@ -60,7 +57,16 @@ public partial class App : Application services.AddSingleton(); services.AddScoped(); + // Platform Services + services.AddSingleton(sp => + new AvaloniaDialogService(GetMainWindow)); + // ViewModels services.AddTransient(); } + + private Window? GetMainWindow() + { + return (ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow; + } }