棱镜,事件发布在外壳没有被抓住模块! [英] Prism, Event published in shell not caught in module!
问题描述
无论如何,无论如何,在实践中,我的控制器不捕获事件。发布或订阅没有错误。我首先想到可能是一个问题,eventAggregator不一样,但事实并非如此,事件有一个订阅者发布时。
可以有人想到为什么事件没有被抓住的原因?
(或任何建议以不同的方式让我的观点显示也将是有帮助的。)
你的模块控制器活着吗?您是否使用弱代理引用或强引用订阅事件?
似乎正在发生的是你的模块控制器被处理,所以事件没有被捕获。
要订阅一个强有力的参考,请使用订阅方法中的 keepSubscriberReferenceAlive 选项。
您可以查看事件聚合从文档中可能提供更多洞察的文章。
如果还是不行,你能和我分享你的复制代码,所以我可以看看吗? (ezequieljadib at hotmail dot com)
谢谢,
Ezequiel Jadib
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!)
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
这篇关于棱镜,事件发布在外壳没有被抓住模块!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!