3
votes

I'm working on a WPF project using Prism and MVVM, I'm new using this tools. I've been creating modules and testing it and everything works fine. To test it in the Bootstrapper I add each module using AddModule method of the ModuleCatalog, but now I need to put all my modules together and go from one module to another.

Program starts and load Module_1, when the user finish all in this module press a complete button and the program shows Module_2 and so on...

What I need to do to change from one module to another after an user action?

Thank you in advance.

2

2 Answers

1
votes

Module can be loaded on demand. After pressing complete button in the first module load Module_2. How to: Load Modules on Demand. In the module's Initialize() method you can register views you need with regions, e.g.

public void Initialize()
{
    regionManager.RegisterViewWithRegion("MainRegion", () => container.Resolve<Module2View>());
}

After load module completed navigate to this view:

moduleManager.LoadModuleCompleted += (s, e) =>
    {
        if (e.ModuleInfo.ModuleName == "Module_2")
        {
            regionManager.RequestNavigate("MainRegion", new Uri("Module2View", UriKind.Relative));
        }
    };

It's just a quick sample. You can find more information on MSDN. Hope it helps.

0
votes

Another option may be to use the EventAggregator class provided by Prism

When the user clicks the complete button a CompositePresentationEvent would be raised. Module_1 and Module_2 would have already subscribed to this event (in their module Initialize methods perhaps) and module_1 can hide itself while module_2 shows itself.

The actual implementation of the showing/hiding of views will depend on how you are using Regions - Zabavsky's answer addresses this.

Hope that make sense!