Question

I'm trying to create an application that includes two shells:

  1. Login shell
  2. Public shell

I success to create two shells at the same time using PRISM and MEF, but how I can first to make the login shell, and after the login success I need to create the public shell?

Thanks

Was it helpful?

Solution

Why don't you handle this issue with two seperate modules,One ,called MainModule, has public shell and another, called AuthenticateModule, has loginView.In order to show LoginView on the shellView, you should consider the order of loading modules and the mode of loginView. Finally I want to say you can do this with both Mef or Unity.

enter image description here

in your bootstraper:

        protected override void InitializeShell()
    {

        base.InitializeShell();
        Application.Current.MainWindow.Show();}

and you should load your AuthenticateModule too:

   protected override void ConfigureModuleCatalog()
    {
        base.ConfigureModuleCatalog();
        ModuleCatalog moduleCatalog = (ModuleCatalog)this.ModuleCatalog;

        Type authenticationModuleType = typeof(AuthenticationModule.AuthenticationModule);
        ModuleCatalog.AddModule(new ModuleInfo(authenticationModuleType.Name, authenticationModuleType.AssemblyQualifiedName));

and in your AuthenticationModule:

public class AuthenticationModule : IModule
{
    ...
    public void Initialize()
    {
        LoginView _loginView = _container.Resolve<LoginView>();

        if (_loginView != null)
        {
            _loginView.Owner = Application.Current.MainWindow;
            _loginView.Show();
        }
    }

OTHER TIPS

A few days ago we had the same problem, and we solved it making a compromise, because of the following scenario:

  1. Prompt the user to login

  2. If success: start user session and application main window

  3. Else: remain on login window

  4. If user logs out, return to login window

The login is in a separate window, and the bootstrapper runs on login success. The login window is hidden, until the user logs out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top