Skip to main content
All docs
V23.2

MVVMContextCompositionRoot Class

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.v23.2.dll

NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core

Declaration

public static class MVVMContextCompositionRoot

Remarks

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);
};

Read the following topic for detailed information and examples: ViewModel Management.

Inheritance

Object
MVVMContextCompositionRoot
See Also