MEF and View Injection

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

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

Dec 22, 2010 at 4:54 PM

Hi,

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.

Thanks,

Miguel Bronzovic
http://blogs.southworks,net/mbronzovic

 

Feb 16, 2011 at 4:35 AM

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

Feb 16, 2011 at 2:15 PM

Hi,

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

Thanks,

Miguel Bronzovic
http://blogs.southworks.net/mbronzovic

 

Feb 16, 2011 at 11:01 PM
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
Hi,
You can check the sample application here. Sorry for the inconvenience.
Thanks,
Miguel Bronzovic
http://blogs.southworks.net/mbronzovic

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

Your new link for sample application no longer works!
Aug 29, 2013 at 7: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
http://blogs.southworks.net/gostrowsky