Files
Kansan/KanSan/App.xaml.cs
2020-07-15 17:18:52 +02:00

60 lines
1.8 KiB
C#

using KanSan.ViewModel;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace KanSan
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MjM0MjUzQDMxMzgyZTMxMmUzMG8wTDNQcm5mN3UxaU9MbjdkVUlQbDgzWHcvUXZCOHdaVVY3c2I5S3BvN0U9");
}
public static IServiceProvider ServiceProvider { get; private set; }
protected override void OnStartup(StartupEventArgs e)
{
FrameworkElement.StyleProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata
{
DefaultValue = FindResource(typeof(Window))
});
FrameworkElement.StyleProperty.OverrideMetadata(typeof(UserControl), new FrameworkPropertyMetadata
{
DefaultValue = FindResource(typeof(UserControl))
});
ServiceProvider = CreateServiceProvider();
Window window = ServiceProvider.GetRequiredService<MainWindow>();
window.Show();
base.OnStartup(e);
}
private IServiceProvider CreateServiceProvider()
{
IServiceCollection services = new ServiceCollection();
services.AddSingleton<SewerMainWindowViewModel>();
services.AddScoped<MainWindowViewModel>();
services.AddScoped<MainWindow>(s => new MainWindow(s.GetRequiredService<MainWindowViewModel>()));
return services.BuildServiceProvider();
}
}
}