- 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
37 lines
1.1 KiB
C#
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;
|
|
}
|