DevExpress MVVM for WPF - New Module Injection Framework Coming Soon in v16.2

02 December 2016

Wait, what? What’s a Module Injection Framework – or MIF – and how is it used? The mile-high overview is that a MIF makes it easier to develop, test, maintain, and deploy applications built with loosely-coupled modules. Such a modular application is one that is divided up into a set of functional units, which are independent from each other. Although viewed as separate, these modules can, if needed, communicate with each other through well-defined contracts that you define. This separation of concerns means that modules can be developed and tested independently of each other.

1. Common Concepts

Using MIF terminology, a module is a set of Views and ViewModels (which can in turn contain submodules) that are injected into regions. A region is merely a placeholder in the application's UI.

MVVM MIF regions and modules

Using the DevExpress MIF, you can create modules and register them via the ModuleManager:

    regionName: "RegionA", 
    module: new Module(
        key: "Module1", 
        viewModelFactory: () => new Module1ViewModel(), 
        viewType: typeof(Module1View)

A region is a control that is marked by an attached property:

<TabControl dxmvvm:UIRegion.Region="RegionA" .../>

Modules are injected to regions when you call the Inject() method:

ModuleManager.Inject(regionName: "RegionA", key: "Module1");

2. Navigation

You can perform navigation tasks anywhere/anywhen in your application, only knowing the key of the module and the name of the target region:

ModuleManager.Navigate(regionName: "RegionA", key: "Module1")

You can also define navigation logic globally. For example, suppose you have two regions in your app: a navigation region and a document region, such as in the image previously shown. An end-user uses the navigation control in its region to navigate to a document, and this is then shown in the document region (which could be a TabControl, for example).

With MIF, you can say:

“When a module in the navigation region becomes active – activate the corresponding module in the document region.”

And also:

“When a document in the document region becomes active – activate the corresponding module in the navigation region.”

ModuleManager.GetEvents(regionName: "NavigationRegion").Navigation += OnNavigationRegionNavigation;

void OnNavigationRegionNavigation(object sender, NavigationEventArgs e) {
    ModuleManager.Navigate(regionName: "DocumentsRegion", key: ((MyNavigationViewModel)e.ViewModel).DocumentKey);


ModuleManager.GetEvents(regionName: "DocumentsRegion").Navigation += OnDocumentsRegionNavigation;

void OnDocumentsRegionNavigation(object sender, NavigationEventArgs e) {
    ModuleManager.Navigate(regionName: "NavigationRegion", key: ((MyDocumentViewModel)e.ViewModel).NavigationKey);

3. Tests

MIF makes it really easy for you to write unit tests for your navigation logic.

ModuleManager.Navigate(regionName: "NavigationRegion", key: "NavigationItem1");
Assert.AreEqual("Document1", ModuleManager.GetRegion(regionName: "DocumentsRegion").SelectedKey);

ModuleManager.Navigate(regionName: "DocumentsRegion", key: "Document2");
Assert.AreEqual("NavigationItem2", ModuleManager.GetRegion(regionName: "NavigationRegion").SelectedKey);

4. Save and Restore Application State

Like it or not, our users expect our applications to save its state and to restore it when restarted. There are several types of state an application is expected to manage in this manner:

  • The state of visual controls. Examples are, the selected grouping and column order of a GridControl, or the position of panels in a DockLayoutManager.
  • Dynamically injected modules, which can be automatically injected on startup. One example of this are the open tabs in a browser.
  • The state of particular View Models.

The DevExpress MIF refers to the first type of state as visual state. The second and third types are grouped into logical state.

The ModuleManager.Save() method allows you to query the current application state.

void Save(string regionName, out string logicalState, out string visualState); 

The ModuleManager.Restore() method restores the saved application state when called.

bool Restore(string logicalState, string visualState); 

5. MVVM MIF Template

To get you started, we’ve added a new project template in our Template Gallery. It generates a simple MIF application.

MVVM MIF app template

Are you using our MVVM with our WPF controls? What do you think of this new feature? Do you think you’ll be trying out this new MIF? Please let us know either below or by emailing us at

Free DevExpress Products – Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We’ll be happy to follow-up.
Noufal Aboobacker 1
Noufal Aboobacker 1

In my openion we already have prism which is well tested and highly modular and above all open source and part of dot net foundation . Instead of reinventing the wheel the better approach would have been to embrace prism and make devexpress wpf more easy to work with this already established framework.

1 December 2016

Who asked for this feature? No interested comment and zero fb likes, as of now.

2 December 2016
Petr Vojtechovsky 1
Petr Vojtechovsky

Hi Julian, is the winform platform supported?

2 December 2016
Norbert K.
Norbert K.

Hi Julian! Could you please explain what are the advantages of your framework over PRISM?

2 December 2016

When I tested all the different MVVM frameworks I found that the devexpress MVVM was the best and most practical. I think if your software is simple it won't matter which you MVVM framework you use. But if your making complex software the open source solutions all seem to have problems and deficits.

3 December 2016
Noufal Aboobacker 1
Noufal Aboobacker 1

@developer_paul, I complete agree with you about the fact that DevExpress MVVM is the best out there. I am using all the features of the MVVM framework quite seamlessly. But when it comes to Modular development, in my openion Prism is the best Period. So creating a new Injection framework was totally a waste of time. instead DevExpress should have provided more and more feature on the MVVM Framework itself.

3 December 2016
Alexander (DevExpress Support)
Alexander (DevExpress Support)

Hi guys,

Let me answer to your question by points.

1. Why MIF and not PRISM.

We seriously considered the possibility to support PRISM.

There is a problem with versioning: how to manage different PRISM versions and a version of our components? If we create a library with PRISM region adapters for our components, it should support all versions of our components and all versions of PRISM (at least, starting with DX version 16.2 and PRISM version 6.2).

This means that we should create a repository on GitHub with many branches - for every version of our components and the PRISM version. It will be hard to sort out all branches.

So, we decided to go another way - to create a solution that is qualitatively integrated with our control from the inside.

2. What are the advantages of your framework over PRISM?

Perhaps the main advantage is the application's state serialization. MIF provides the capability to restore previously opened documents and their layout.

3. Is the winform platform supported?

No, but we will consider it in the future. Prospects are very optimistic in the sense that there should be not serious problem in porting to WinForms.

4 December 2016
Noufal Aboobacker 1
Noufal Aboobacker 1

Hi Alexander,

I understand your point. But there are lots of projects which are already using prism and being a wpf control vendor its a must that you should support prism because its part of Microsoft .net foundation. There is no problem if DevExpress has its own solutions but those who work with Prism should also have some better options.

I think you can still create those GitHub repositories and since it will be open sourced I am sure many will contribute so all the users will get best of both worlds.

Please consider this.

4 December 2016
Alexander (DevExpress Support)
Alexander (DevExpress Support)

Yes, this makes sense.

Let's see if we will support PRISM in the future.

5 December 2016
Marvin Kruse
Marvin Kruse

We have plans to modularize an application we're currently working on in Q1 2017 (we're already using DX) - but with this approach we do not need write a lot of code ourselfs and just use MIF. Nice one!

22 December 2016

More documentation are needed ....!

23 December 2016
Valdimar Halldorsson 1
Valdimar Halldorsson 1

I agree with Noufal, please create a Gitbub repo DX-Prism support as it's the framework I've used in the past and will be working with in the future.

23 December 2016

MIF is a great addition to your MVVM framework. I feel like that's the piece that's been missing. REALLY need some good documentation on it though.

I understand why you are doing your own because you can have tighter integration with your controls and not everyone uses Prism. However, I would agree that if you could maintain an open source project for Prism adapters, etc. that would be great!

22 February 2017

I am surprised that you have come up with some parallel composite solution to Prism. At initial stages of my own modular application design I looked deeply into Prism and tried to use some of DevExpress View controls with it. Soon I hit some road blocks, especially with Shell & region view injection concepts of Prism along with DevExpress controls. I have found that Prism has certain limitations and somewhat bloated in certain ways. So I have decided to take the best of Prism guidelines (ModuleManager, ModuleCatalog, ModuleInfo, bootstrapper and IoC container integration etc.) and created a BootStrapper architecture but much simplifed without all the bloat of Prism. Kept the Shell concept aside and used MarkUpExtentions instead to inject ViewModels into DevExpress View controls. I use (the very fast) SimpleInjector for target class (ViewModel/Service) registration. If I need to introduce a new module, all I have to do is to add a single line of code at my BootStrapper into the Module Catalog.

I will look into your new Module Injection Framework in detail but from what I can see, I am struggling to understand the real benefit of it or what kind of extensive benefits it will provide to developers.


8 March 2017
Edu van Zyl
Edu van Zyl

Hi Alexander/Julian

This looks promising but the MIF Template project explicitly registers and injects each module and the main project has a hard reference to the modules project.

Is it possible to discover and register/inject modules in a directory and/or based on a configuration file?

I'm in early stages of designing a modular application where the customer requires the ability to add and/or swap out modules. I know this can be done with Prism but it would be nice if I can just use MIF instead.

And are there any documentation on this?

15 March 2017
Klaus  Wiesel
Klaus Wiesel

Hi. I also am very curious about discovering from file system, is there any demo out there showing this?

27 March 2018

Please login or register to post comments.