Prism CAG - WPF - 模块的新实例? 它只是克隆实例吗?

发布于 2024-07-25 00:03:58 字数 476 浏览 3 评论 0 原文

我正在使用 Prism 的 CAG 开发 WPF 应用程序。 我想要实现的是创建模块(ModuleA)的新实例并将它们加载到 TabControl 中。 我可以使用 moduleInfo 对象实例化模块,并通过 Assembly 加载它们并调用 CreateModule(type) 方法。

我实际上可以在 UI 中看到不同的模块,但问题是当我开始与不同的模块交互时(例如在作用域区域中加载或卸载视图),所有活动似乎只发生在最后加载的模块上。

例如,我有 2 个 ModuleA“实例”作为 2 个 TabItem,它们都有用于 Load() 新视图的命令按钮。 当我选择第一个模块(通过选择第一个 TabItem)并单击按钮加载视图时,视图将加载到第二个模块中。

有人知道如何解决这个问题吗? 让我相信,即使我在 UI 上“看到”两个单独的模块,实际上只有一个实例或者 CreateModule 创建克隆?

任何人 ? 感谢所有帮助!

I am developing a WPF application using the CAG from Prism. What I want to achieve is create new instances of a module (ModuleA) and load them in a TabControl.
I am able to instantiate the modules using the moduleInfo object and loading them through the Assembly and calling the CreateModule(type) method.

I can actually see the different modules in the UI, but the problem is when I start interacting with the different modules (for e.g. loading or unloading views in scoped regions) all the activity seems to happen only on the last loaded modules.

So for e.g. I have 2 'instances' of ModuleA as 2 TabItems and they both have command buttons to Load() new views. When I select the first Module (by selecting the first TabItem) and click the button to laod the view, the view gets loaded in the second module.

Anyone know how to sort this problem? Makes me believe, even if I 'see' two seperate modules on the UI, there is actually only one instance or the CreateModule creates clones ?

Anyone ? all help appreciated !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

为你拒绝所有暧昧 2024-08-01 00:03:58

正如 Erik 所解释的,加载模块和视图在 Prism 中是非常不同的概念。

在理解这一点并处理与问题中类似的场景时,以下线程非常有用:

我希望这有用。

谢谢,
达米安

As Erik explained, loading Modules and Views are very different concepts in Prism.

The following threads are useful when understanding this and deal with a scenario similar to the one from the question:

I hope this is useful.

Thanks,
Damian

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文