Mef - Prism

Topics: Prism v4 - Silverlight 4
Jun 6, 2010 at 2:14 PM

Hi, 

I didn't understand how we can register view/presenter to the new MEF container, that the view/presenters use injection or MEF 'Import'?

In the MEF ex. there is no explanation on how we can register views presenters & services in the module.

 

Thanks

 

Jun 7, 2010 at 8:53 PM

Same here, how can we inject the views using mef modules? :(

Developer
Jun 10, 2010 at 6:27 PM
Edited Jun 10, 2010 at 6:27 PM

Hi,

As this is the first drop of Prism v4 (and is in alpha state), there is currently no guidance on using MEF for MVVM/MVP. As regards to MEF, the current drop only contains guidance for modularity.

You can, however, use MEF’s ‘Export’ and ‘Import’ capabilities to register your views, presenters and services in the CompositionContainer (you can check the MEF documentation to see how this is done).

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

Jun 19, 2010 at 2:44 AM

@keoz, @hilla_benita

With MEF there's no need to do an explicit registration of views / services. You simply annotate your views as Exports and they will be automatically registered when the module is loaded. As to writing up VMs to views there are several possibilities including the following common approaches.

Regradless of which approach you use the import thing is that the Views and VMs do not have to be manually registered. They are simply exported.

Regards

Glenn

Jun 20, 2010 at 9:08 AM

Thanks for your answer.

If I understand right there is no need for Prism if we use MEF,

There is no need in unity container and aggregation events...

so what the benefit that Prism get me except of regions?  

 

Hilla

Jun 20, 2010 at 6:09 PM
Edited Jun 20, 2010 at 6:10 PM

I don't think I said that :-) I was pointing out that you don't need to specifically register views and view models as they can be exported and MEF will discover them.

On the top of MEF and Prism, they are really orthagonal to one another. There is some overlap from a library perspective but Prism is more than just libraries, and the two can be blended. Check this thread: http://mef.codeplex.com/Thread/View.aspx?ThreadId=216547

 

Jun 21, 2010 at 6:17 AM
thanks
Jun 27, 2010 at 5:32 AM
hilla_benita wrote:

Hi, 

I didn't understand how we can register view/presenter to the new MEF container, that the view/presenters use injection or MEF 'Import'?

In the MEF ex. there is no explanation on how we can register views presenters & services in the module.

Thanks

 I wrote a sample that utilizes the MVPVM pattern (presenter handles business logic) using Prism V4 Drop 2; perhaps it might give you some ideas on how you could address your requirements.

http://www.global-webnet.net/blogengine/post/2010/06/26/PRISM-V4-Drop-2-MVPVM-Modularity-with-MEF.aspx