每个模块的菜单项,模块内容使用 Prism 或 MEF 动态加载
我目前正在使用 Prism 和 MEF 开发一个应用程序。
理想情况下,我希望为每个模块生成一个带有项目的工具栏或菜单,并且当单击某个项目时,只有在该模块中声明的视图才会加载到选项卡控件中。
例如:
菜单区域: 模块A(已选) | ModuleB
选项卡区域: 模块A视图A |模块A视图B | ModuleAViewC
更改为 菜单区域: 员工 |库存(选定)
选项卡区域: 项目 |在菲
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有很多类似的问题。一般来说,您将采取的方法是在您的模块可以引用的基础结构 DLL 中定义服务。您的模块将通过服务添加菜单/工具栏/功能区项目/任何对象。服务的实现位置由您决定 - 可以在 Shell 项目、基础设施或单独的模块中。显然,如果它位于单独的模块中,您必须确保其他模块将其定义为依赖项。
您可能需要查看以下内容:
此内容有一个演示动态菜单的项目的链接:
寻找模块将自身加载到 a 中的 Prism 示例menu
其中我问了一个关于如何构建动态菜单的问题:
如何动态添加菜单项(使用header) 到 WPF 菜单
更多...
加载区域中的模块默认视图以创建菜单
并且更多的!
Prism 应用程序 CAL 中的菜单服务
您还可以在那里找到更多内容。这是一个相当普遍的要求;我相信您可以从现有的代码示例中拼凑出一个很好的方法来实现这一点。
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.