简体   繁体   English

PRISM WPF(MEF)-另一个Shell中的Shell

[英]PRISM WPF (MEF) - Shell within another Shell

I have a few important logical components in my application and I am planning to create them as different PRISM shells with their own modules. 我的应用程序中有一些重要的逻辑组件,我计划将它们创建为具有各自模块的不同PRISM shell。 Though they currently can be independent modules, we might get a request to launch them all from within a single big form at a later stage. 尽管它们目前可以是独立的模块,但我们可能会在稍后阶段收到从一个大型表单中全部启动它们的请求。 So if that happens, I will have to launch the Prism "shells" that I will write now from the bigger shell. 因此,如果发生这种情况,我将必须启动现在将要从较大的Shell编写的Prism“ shell”。 Is that even possible? 那有可能吗? Can I load a shell within another shell (- maybe like a tab for each of my inner shell). 我可以将一个外壳加载到另一个外壳中吗(-就像每个内部外壳的选项卡一样)。 If I cannot, what are the general alternatives or any design suggestions that I can consider now. 如果不能,我现在可以考虑哪些一般替代方案或任何设计建议。 I am still in the design phase of the app and I can move away from PRISM if it turns out to be very rigid once implemented. 我仍处于应用程序的设计阶段,并且一旦实现就非常僵化,我可以放弃PRISM。

In order to load each Shell on a separate window, you could checkout the following post that shows a sample in Prism-v2 of creating a multi-shell application. 为了将每个Shell加载到单独的窗口中,您可以签出以下文章,该文章显示了Prism-v2中创建多外壳应用程序的示例。 However, it would be quite simple to adapt it to Prism 4 : 但是,将其适应Prism 4将非常简单:

By using one single Bootstrapper for every Module would make easier in the future to extend communication between them. 通过为每个模块使用单个Bootstrapper ,将来会更容易扩展它们之间的通信。 You may also need to set an update the RegionManager on every Window to properly register every Region of every Shell as decribed in the sample. 您可能还需要在每个Window上设置一个RegionManager更新,以正确注册示例中描述的每个Shell的每个Region

Besides the RegionManager , the rest of the services provided by Prism , such as the EventAggregator or the ModuleManager , are independent of the UI / Regions of the application, so you should be able to use them in all the windows without problems. 除了RegionManager之外Prism提供的其余服务(例如EventAggregatorModuleManager )都独立于应用程序的UI / 区域 ,因此您应该可以在所有窗口中使用它们而不会出现问题。

Nevertheless, if you would load each Shell on separate tabs, you could define the TabRegion as TabControl on the main Shell App and then register and load each of your inner Shells on the TabRegion like they were simple Views . 不过,如果你会加载每个贝壳上的独立选项卡,你可以定义TabRegionTabControl的外壳应用程序 ,然后注册,并加载每个内TabRegion像他们简单的浏览 Registering the Views on each Module's Initialize() method would load every View after initialization finishes. 在每个模块的 Initialize()方法上注册视图将在初始化完成后加载每个视图

For more information about Managing Modules and Regions , you may find the following MSDN Prism Guide chapters useful: 有关管理模块区域的更多信息,您可能会发现以下《 MSDN Prism指南》各章有用:

I hope this helped you, 希望对您有帮助,

Regards. 问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM