windowsforms-devexpress-dot-utils-dot-mvvm-b530fbcb.md
Allows you to bind data types created by DevExpress MVVM Framework at runtime to a dependency injection framework.
Namespace : DevExpress.Utils.MVVM
Assembly : DevExpress.Utils.v25.2.dll
NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core
public static class MVVMContextCompositionRoot
Public Module MVVMContextCompositionRoot
The MVVMContextCompositionRoot class exposes the ViewModelCreate event that allows you to bind data types created by DevExpress MVVM Framework at runtime to a dependency injection framework (for example, Ninject).
// Retrieve the live POCO ViewModel instance with the Ninject kernel
//regular event
mvvmContext1.ViewModelCreate += MVVMContext_ViewModelCreate;
void MVVMContext_ViewModelCreate(object sender, DevExpress.Utils.MVVM.ViewModelCreateEventArgs e) {
// kernel.Bind<SamuraiViewModel>().To(e.RuntimeViewModelType);
// e.ViewModel = kernel.Get<SamuraiViewModel>();
e.ViewModel = kernel.Get(e.RuntimeViewModelType);
}
//static event
MVVMContextCompositionRoot.ViewModelCreate += (s,e)=> {
e.ViewModel = kernel.Get(e.RuntimeViewModelType);
};
' Retrieve the live POCO ViewModel instance with the Ninject kernel
'regular event
AddHandler mvvmContext1.ViewModelCreate, AddressOf MVVMContext_ViewModelCreate
void MVVMContext_ViewModelCreate(Object sender, DevExpress.Utils.MVVM.ViewModelCreateEventArgs e)
' kernel.Bind<SamuraiViewModel>().To(e.RuntimeViewModelType);
' e.ViewModel = kernel.Get<SamuraiViewModel>();
e.ViewModel = kernel.Get(e.RuntimeViewModelType)
'static event
AddHandler MVVMContextCompositionRoot.ViewModelCreate, Sub(s,e) e.ViewModel = kernel.Get(e.RuntimeViewModelType)
Read the following topic for detailed information and examples: ViewModel Management.
Object MVVMContextCompositionRoot
See Also