Hi I have a Silverlight application I've designed using MVVM patterns and Prism.
It has a number of modules that I would only like to load once the user has authenticated.
To this end I have created a login module, that takes the clients credentials and handles a开发者_StackOverflowuthentication. Once the user is authenticated I would then like MEF to load the rest of the modules. My problem is how to accomplish this?
The module catalog is defined in xaml and all modules except the login module are set to OnDemand initialization. As far as I'm aware modules can only be loaded from the shell, which doesn't work in my case as the call for them to load would come from the loginmodules viewmodel.
Any ideas would be greatly appreciated, thanks.
Prism provides an IModuleManager which you can import through MEF or Unity and then use to load modules.
[ImportingConstructor]
public MyViewModel(IModuleManager moduleManager)
{
this.moduleManager = moduleManager;
this.moduleManager.LoadModule("ModuleA");
}
精彩评论