Passing Services to MainViewModel - SHOULD I use a dependency injection container ?
- by msfanboy
Hello,
I have this code:
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var mainVM = new MainViewModel
(
new Service1(),
...
new Service10(),
);
var window = new MainWindow();
window.DataContext = mainVM;
window.Show();
}
}
I pass all my Services instances to the MainViewModel. Within the MainViewModel I spread those services to other ViewModels via constructor parameter passing.
Should I use any DI framework for the services in the App class?
If yes whats the benefit of resolving the services instead of just creating the instance manually... ?