Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wpf Prism MVVM change between modules

Tags:

c#

mvvm

wpf

prism

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.

like image 655
estebane97 Avatar asked Nov 24 '25 02:11

estebane97


1 Answers

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.

like image 79
Zabavsky Avatar answered Nov 26 '25 15:11

Zabavsky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!