[Export] vs [ViewExport(RegionName = RegionNames.ResearchRegion)] in StockTrader

Topics: Prism v4 - WPF 4
Aug 14, 2012 at 9:20 PM



I've just started playing with Prism and love it.. very easy to pick up...


In looking at the StockTrader RI demo though, I am not to sure what the difference is between the regular [export] MEF attribute and the custom [ViewExport(RegionName =  RegionNames.ResearchRegion)] attribute used in the demo...


Also the method AutoPopulateExportedViewsBehavior()... what is this doing that is different from how views are injected into a region normally?




Aug 15, 2012 at 3:27 PM
Edited Aug 15, 2012 at 3:29 PM

Hi Harold,

Based on my understanding, the main difference is that using a Custom Export Attribute allows associating information with your exports, which can be used by your imports to constraint the export that can satisfy them. This way, the AutoPopulateExportedViewsBehavior discovers the views in the container exported with this custom attribute and automatically populates them into the associated region.

You could find more detailed information about the use of MEF Custom Export Attributes in the following resource:

Also, you will find that this approach is similar to the one used by the view discovery approach which uses the AutoPopulateRegionBehavior to populate the regions with its associated views, although this approach register views in code instead of using declarative attributes.

For more information about this, and the different approaches provided by Prism to compose your UI, you could check the following chapter of the Prism documentation:

I hope you find this helpful,

Agustin Adami

Aug 22, 2012 at 3:43 AM

Hi Agustin,


Thanks very much for the info! helpful!