Prism,在 shell 中发布的事件未在模块中捕获!

发布于 2024-07-26 13:34:35 字数 367 浏览 1 评论 0原文

我有一个 wpf 复合应用程序,其中包含 3 或 4 个模块,并且始终会加载。 在我的 shell 中,我有一个工具栏,其中包含用于激活这些模块中相应视图的按钮。 我将 IEventAggregator 注入到 shell 呈现器中,以便当按下按钮时我可以发布相应模块控制器已订阅的事件。 当事件被捕获时,控制器将激活其视图。

无论如何,这就是理论,实际上我的控制器没有捕获事件。 发布或订阅时没有错误。 我一开始以为 eventAggregator 不一样可能会出现问题,但事实并非如此,并且事件在发布时有一个订阅者。

有人能想到该事件没有被捕获的原因吗? (或者任何关于以不同方式展示我的观点的建议也会很有帮助!)

I have a wpf composite application with 3 or 4 modules that will always be loaded. In my shell I have a toolbar with buttons to active corresponding views from these modules. I injected an IEventAggregator into the shell presentor so that when a button is pressed I can publish an event that the corresponding module controller has subscribed to. When the event is caught the controllor will active its view.

Thats the theory anyways, in practice my controller is not catching the event. There are no errors in publishing or subscribing. I thought at first that there might be an issue with the eventAggregator not being the same, but thats not the case, and the event has a subscriber when its published.

Can anyone think of a reason why the event is not getting caught?
(Or any suggestions on a different way to get my view to show would be helpful too!)

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

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

发布评论

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

评论(1

单身情人 2024-08-02 13:35:46

您的模块控制器“活跃”吗? 您是使用弱委托引用还是强引用订阅事件?
似乎正在发生的事情是您的模块控制器正在被处置,因此该事件没有被捕获。

要订阅强引用,请使用 Subscribe 方法上的 keepSubscriberReferenceAlive 选项。

您可以查看文档中的事件聚合器文章,该文章可能提供更多信息洞察力。

如果仍然不起作用,您可以与我分享您的重现代码,以便我看一下吗? (ezequieljadib at hotmail dot com)

谢谢,

Ezequiel Jadib

Do you have your module controller 'alive'? Are you subscribing to the event using weak delegate reference or strong reference?
Seems that what is happening is that your module controller is being disposed, and so, the event is not getting caught.

To subscribe with a strong reference, use the keepSubscriberReferenceAlive option on the Subscribe method.

You can check the Event Aggregator article from the documentation which might provide more insight.

If that still does not works, can you share your repro code with me so I can take a look to it? (ezequieljadib at hotmail dot com)

Thanks,

Ezequiel Jadib

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