Passing Services to MainViewModel - SHOULD I use a dependency injection container ?
Posted
by
msfanboy
on Stack Overflow
See other posts from Stack Overflow
or by msfanboy
Published on 2011-01-02T00:13:45Z
Indexed on
2011/01/02
3:53 UTC
Read the original article
Hit count: 175
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... ?
© Stack Overflow or respective owner