diff --git a/Frank.Wpf.Hosting/ServiceCollectionExtensions.cs b/Frank.Wpf.Hosting/ServiceCollectionExtensions.cs index 4968a43..6c1ae68 100644 --- a/Frank.Wpf.Hosting/ServiceCollectionExtensions.cs +++ b/Frank.Wpf.Hosting/ServiceCollectionExtensions.cs @@ -12,6 +12,7 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddPage(this IServiceCollection services) where T : Page { services.AddTransient(); + services.AddTransient(provider => provider.GetRequiredService()); return services; } @@ -22,9 +23,31 @@ public static IServiceCollection AddWindow(this IServiceCollection services) return services; } + public static IServiceCollection AddContentControl(this IServiceCollection services) where T : ContentControl + { + services.AddTransient(); + services.AddTransient(provider => provider.GetRequiredService()); + return services; + } + public static IServiceCollection AddControl(this IServiceCollection services) where T : Control { services.AddTransient(); + services.AddTransient(provider => provider.GetRequiredService()); + return services; + } + + public static IServiceCollection AddUserControl(this IServiceCollection services) where T : UserControl + { + services.AddTransient(); + services.AddTransient(provider => provider.GetRequiredService()); + return services; + } + + public static IServiceCollection AddFrameworkElement(this IServiceCollection services) where T : FrameworkElement + { + services.AddTransient(); + services.AddTransient(provider => provider.GetRequiredService()); return services; } } \ No newline at end of file