MEF and View Injection

Topics: Prism v4 - Silverlight 4, Prism v4 - WPF 4
Dec 21, 2010 at 8:46 PM

Can someone please give me an example of using View injection strategy for application using MEF container?

Dec 22, 2010 at 5:54 PM


View Injection can be used independently of the dependency injection container you choose for your application. That means, it will work not only with MEF but also with Unity, or any other dependency injection container of your own preference.

The difference between MEF and Unity for View Injection is how you resolve the view to inject into regions. As documentation shows, “In view injection, your code obtains a reference to a region, and then programmatically adds a view into it…Your code will query a RegionManager for a specific region by name and then inject views into it…

You can read more about View Injection in Chapter 7: Composing the User Interface, specifically in Displaying Views in a Region Programmatically section.

You might also find useful the following chapters of Prism documentation:

Additionally, I've created a sample application in which View Injection is done using MEF. Note that I've used the Service Locator to retrieve the instance of the view, but you could also use any other approach to retrieve it using MEF, as required by your scenario.

I hope you find this information useful.


Miguel Bronzovic


Feb 16, 2011 at 5:35 AM

Your link for sample application no longer works - I'd still like to check it out!

Feb 16, 2011 at 3:15 PM


You can check the sample application here. Sorry for the inconvenience.


Miguel Bronzovic


Feb 17, 2011 at 12:01 AM
Cheers thanks for that!

- Wajid

From: [email removed]
To: [email removed]
Date: Wed, 16 Feb 2011 07:15:18 -0800
Subject: Re: MEF and View Injection [CompositeWPF:239160]

From: mbronzovic
You can check the sample application here. Sorry for the inconvenience.
Miguel Bronzovic

Read the full discussion online.
To add a post to this discussion, reply to this email (
To start a new discussion for this project, email
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at
Aug 29, 2013 at 1:18 PM
hi gunungmerapi,

Your new link for sample application no longer works!
Aug 29, 2013 at 8:36 PM
Hello spsoofbaf,
I´ve just verified the last available link for the sample application and it worked for me.
Anyway, I uploaded the sample again into my SkyDrive Public folder so you can access it without any problem. Find the ViewInjectionWithMEF sample in the following link:
Please, let me know if you have any issues.

Gabriel Ostrowsky