Search code examples
prismmef

Autopopulateregionbehaviour + MEF


I am writing a new application which registers views within regions automatically using the PRISM AutoPopulateRegionBehaviour. This works fine when I register the views at app startup, however I am trying to use the MEF DeploymentCatalog to download a new XAP and update the region however this doesn't appear to be working (no views are displayed) and setting a breakpoint in the region behaviour. I'll try and upload a small snippet later but I wanted to pre-empt whether this should be possible or whether I need to call something to force the regions to refresh.

Thanks.


Solution

  • Sorted. The problem was that the RegisteredViews Import wasn't being satisfied, the reason for this was that I was importing the viewmodel by interface type rather than by concrete type i.e.

    I renamed:

    [Import] public IABCViewModel ViewModel { set { this.DataContext = value; } }

    to:

       public ABCViewModel ViewModel
        {
            set
            {
                this.DataContext = value;
            }
        }
    

    I think this is because I need to register a type mapping for the interface to the concrete type (though this wasnt necessary in WPF).