I am assuming that when in NinjectModule I bind
Bind<SplashViewModel>().ToSelf().InSingletonScope();
an instance of SplashViewModel is being kind of a cached in Ninject kernel and each time I call kernel.Get<SplashViewModel> I would be getting the very same instance of a view model returned to me. This is what happens, true.
In my NinjectUIModule I call:
Bind<SplashViewModel>().ToSelf().InSingletonScope();
Bind<SplashWindow>().ToMethod(context => new SplashWindow()
{
DataContext = new SplashViewModel()
});
The problem is that a SplashWindow gets a different new instance of SplashViewModel, not the instance that is cached in Ninject kernel and is returned to all other retrieving parties.
How can I bind view model to a View’s DataContext in a Ninject module, and allow it to be returned via kernel.Get to other code in the application later.
If your SplashWindow would take the SplashViewModel as a ctor arg, then that initialization would be taken care for you by Ninject. You will not even need to define the SplashWindow binding.