Search code examples
wpfmvvmprismmef

How to resolve view using Mef container in a view model


I have a view model containing a command where I want to add a new view to my shell's MainRegion (a tab control).

Seems to be that I need to use view injection rather than discovery which is fine.

i.e. from the prism documentation

IRegionManager regionManager = ...;
IRegion mainRegion = regionManager.Regions["MainRegion"];
NewView view = this.container.Resolve<NewView>();
mainRegion.Add(view);

How and where do I get a reference to the CompositionContainer in my view model in order to resolve NewView?

Thanks.


Solution

  • This question is effectively the same as yours.