I'm getting into Ninject. Simplifying my real scenario, I have a class A with property injection:
public class NinjectBindings : NinjectModule
{
public override void Load()
{
Bind<IMasterViewModel>().To<IQMasterViewModel>();
}
}
public class A
{
[Inject]
public IMasterViewModel _viewModel
{
get;
set;
}
public A()
{
}
}
And a class B that instantiate A via default constructor:
public class B
{
public A a = new A();
}
Ninject.IKernel kernel = new StandardKernel(new NinjectBindings());
var b = kernel.Get<B>();
If I try to resolve class B using Ninject.kernell.Get() call the dependency of class A will not be injected into A instance. Can anyone suggest what is the correct way to handle such injection if I can't change the way object A is instantiated? Because in real scenario class B is a WPF Window and class A is a UserControl declared in XAML. Thanks.