开发者

On Demand module loading with MEF Prism and Silverlight

开发者 https://www.devze.com 2023-04-04 08:53 出处:网络
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.

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");
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号