Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Menu item for each module, with module content loading dynamically with Prism or MEF

I am developing an application currently using Prism and MEF.

I would ideally like to generate a toolbar or menu with an item for each module, and when an item is clicked, only the views declared within that module load into a tab control.

For example:

Menu Region: ModuleA(Selected) | ModuleB

Tab Region: ModuleAViewA | ModuleAViewB | ModuleAViewC

Changes to Menu Region: Employees | Inventory(selected)

Tab Region: Items | In Fi

like image 207
digiteknique Avatar asked Feb 02 '23 23:02

digiteknique


1 Answers

There are a lot of questions similar to this on here. In general, the approach you'll take is to define a service in an infrastructure DLL that your modules can reference. Your modules will add menu / toolbar / ribbon item / whatever objects through the service. Where the service is implemented is up to you - it can be in the Shell project, the infrastructure, or in a seperate module. Obviously, if its in a seperate module, you'll have to make sure that your other modules define it as a dependency.

You may want to check out the following:

This one has a link to a project demonstrating a dynamic menu: Looking for Prism example of Modules loading themselves into a menu

In which I ask a question on how to build a dynamic menu: How to dynamically add MenuItems (with a header) to a WPF menu

More.... Load Module Default Views In Region to Create Menu

And more! Menu service in Prism application CAL

You can find more than this as well out there. This has been a fairly common request; I'm sure you can piece together a good approach for doing this from the code samples out there.

like image 134
Matt Jordan Avatar answered Feb 06 '23 02:02

Matt Jordan