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
This commit is contained in:
Dev
2026-04-02 12:38:31 +02:00
parent b41599d95a
commit cb7cf93c52
5 changed files with 105 additions and 2 deletions

View File

@@ -0,0 +1,60 @@
<Window x:Class="SharepointToolbox.Views.Dialogs.ProfileManagementDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:loc="clr-namespace:SharepointToolbox.Localization"
Title="Manage Profiles" Width="500" Height="480"
WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
ResizeMode="NoResize">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Profile list -->
<Label Content="Profiles" Grid.Row="0" />
<ListBox Grid.Row="1" Margin="0,0,0,8"
ItemsSource="{Binding Profiles}"
SelectedItem="{Binding SelectedProfile}"
DisplayMemberPath="Name" />
<!-- Input fields -->
<Grid Grid.Row="2" Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[profile.name]}"
Grid.Row="0" Grid.Column="0" />
<TextBox Text="{Binding NewName, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="0" Grid.Column="1" Margin="0,2" />
<Label Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[profile.url]}"
Grid.Row="1" Grid.Column="0" />
<TextBox Text="{Binding NewTenantUrl, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1" Grid.Column="1" Margin="0,2" />
<Label Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[profile.clientid]}"
Grid.Row="2" Grid.Column="0" />
<TextBox Text="{Binding NewClientId, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="2" Grid.Column="1" Margin="0,2" />
</Grid>
<!-- Buttons -->
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[profile.add]}"
Command="{Binding AddCommand}" Width="60" Margin="4,0" />
<Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[profile.rename]}"
Command="{Binding RenameCommand}" Width="60" Margin="4,0" />
<Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[profile.delete]}"
Command="{Binding DeleteCommand}" Width="60" Margin="4,0" />
<Button Content="Close" Width="60" Margin="4,0"
Click="CloseButton_Click" IsCancel="True" />
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,19 @@
using System.Windows;
using SharepointToolbox.ViewModels;
namespace SharepointToolbox.Views.Dialogs;
public partial class ProfileManagementDialog : Window
{
public ProfileManagementDialog(ProfileManagementViewModel viewModel)
{
InitializeComponent();
DataContext = viewModel;
Loaded += async (_, _) => await viewModel.LoadAsync();
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
}