You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace AIK.Service.Extensions
|
|
{
|
|
public class WindowFactory : IWindowFactory
|
|
{
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
public WindowFactory(IServiceProvider serviceProvider)
|
|
{
|
|
_serviceProvider = serviceProvider;
|
|
}
|
|
|
|
public Window CreateWindow(Type windowType)
|
|
{
|
|
return (Window)_serviceProvider.GetRequiredService(windowType);
|
|
}
|
|
|
|
public Window CreateWindow(Type windowType, Type viewModelType, object viewModel = null)
|
|
{
|
|
var window = (Window)_serviceProvider.GetRequiredService(windowType);
|
|
|
|
//if (viewModel != null && window.DataContext == null)
|
|
//{
|
|
// window.DataContext = viewModel;
|
|
//}
|
|
|
|
return window;
|
|
}
|
|
|
|
}
|
|
}
|
|
|