To add to what the user billism is posting:
What you are saying seems to be correct, when using MEF it’s not a common practice to resolve objects using the container. Instead, the objects are commonly injected using the
[ImportingConstructor] or [Import] attributes as you have mentioned.
However, it is possible to resolve the objects using the CompositionContainer’s
GetExportedValue method. For example, in the Bootstrapper of the
Modularity for Silverlight with MEF QuickStart this container is used to obtain an instance of the
Shell, as shown in the code below:
protected override DependencyObject CreateShell()
Note that you have to export the CompositionContainer in order to use it from another component (such as a module) and, as mentioned above, this is not a common practice.
Another approach for this case could be using an
overload of the RegistryViewWithRegion method which accepts a type instead of an instance:
Or to use the ServiceLocator to resolve the view:
this.regionManager.RegisterViewWithRegion("MainRegion", () => ServiceLocator.Current.GetInstance<EmployedView>() );
Note that these two approaches can be applied regardless of whether you are using MEF or Unity (as the service locator abstracts away of the container that is being used, and using the
RegisterViewWithRegion method passing the type of the view will internally use the service locator to resolve an instance of it).
I hope you find this useful.
Guido Leandro Maliandi