Files
Sharepoint-Toolbox/SharepointToolbox/MainWindow.xaml.cs
Dev cb7cf93c52 feat(01-07): add ProfileManagementDialog with DI factory wiring
- Create Views/Dialogs/ProfileManagementDialog.xaml (modal Window with Name/TenantUrl/ClientId fields and TranslationSource bindings)
- Create Views/Dialogs/ProfileManagementDialog.xaml.cs (DI constructor injection, LoadAsync on Loaded)
- Add OpenProfileManagementDialog factory delegate to MainWindowViewModel
- Wire ManageProfilesCommand to open dialog via factory, reload profiles after close
- Register ProfileManagementDialog as Transient in DI (App.xaml.cs)
- Inject IServiceProvider into MainWindow constructor for DI-resolved dialog factory
2026-04-02 12:38:31 +02:00

37 lines
1.1 KiB
C#

using System.Windows;
using System.Windows.Controls;
using Microsoft.Extensions.DependencyInjection;
using SharepointToolbox.ViewModels;
using SharepointToolbox.Views.Dialogs;
using SharepointToolbox.Views.Tabs;
namespace SharepointToolbox;
public partial class MainWindow : Window
{
private readonly MainWindowViewModel _viewModel;
public MainWindow(MainWindowViewModel viewModel, IServiceProvider serviceProvider)
{
InitializeComponent();
_viewModel = viewModel;
DataContext = viewModel;
// Wire profile management dialog factory
viewModel.OpenProfileManagementDialog = () => serviceProvider.GetRequiredService<ProfileManagementDialog>();
// Replace Settings tab placeholder with the DI-resolved SettingsView
SettingsTabItem.Content = serviceProvider.GetRequiredService<SettingsView>();
Loaded += OnLoaded;
}
private async void OnLoaded(object sender, RoutedEventArgs e)
{
await _viewModel.LoadProfilesAsync();
}
// Expose the LogPanel RichTextBox (generated by x:Name="LogPanel") for LogPanelSink wiring
public RichTextBox GetLogPanel() => LogPanel;
}