How can I activate / deactivate a module view after its initialization?

This refers to the composite application guide for WPF or Prism.

I have one "MainRegion" in my shell. My various modules will be uploaded to this main region. I can fill out the list of available modules in the menu and select them for download. On the menu click I do:

var module = moduleEnumerator.GetModule(moduleName);
moduleLoader.Initialize(new[] { module });

For the first time, everything works fine, because the Initialize () methods of the modules are executed, but after the initialization of Module1, Module2 and Module3, nothing happens when I load Module2 again.

My question is: how can I activate the module on demand after it is initialized?

Thank you for your help!

+3
source share
4

. . .

Initialize . , , LoadModule, , , Initilalize . . , .

, ( , IUnityContainer IRegionManager)...

// Get a view from the container.
var view = Container.Resolve<MyView>();

// Get the region.
var region = RegionManager.Regions["MyRegion"];

// Activate the view.
region.Activate(view);

, , .

+4

, " ".

public void RemoveViewFromRegion(string viewName, string regionName, object defaultView)
    {
      IRegion region = regionManager.Regions[regionName];
      object view = region.GetView(viewName);
      region.Remove(view);
      region.Activate(defaultView); 
    }
+2

You must have a ContentControl that will be your region. Then you will need to add all your modules to this region. When you click on the menu, you must use the Activate (...) region method to activate a specific module.

0
source

Does this mean when you activate a module, then other modules that may overlap with it are installed on Visibility.Collapsed?

0
source

All Articles