Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.v24.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