Prism CompositePresentationEvent触发两次

kla*_*ist 1 c# wpf prism

在我的基础架构中,我发布了一个事件

  this.eventAggregator.GetEvent<ReportAddedEvent>().Publish(report);
Run Code Online (Sandbox Code Playgroud)

该报告是一个对象

在我的控制器中,我订阅了此事件

  this.eventAggregator.GetEvent<ReportAddedEvent>().Subscribe(this.OnReportAdded);
Run Code Online (Sandbox Code Playgroud)

我的问题是事件触发两次。整个代码中没有其他地方可以发布该事件,因此可以确定该事件不会在其他地方触发,我可以看到它仅触发一次。

任何人都有建议或解决问题的方法,或者知道问题出在哪里。

Jeh*_*hof 5

我认为问题在于代码

this.eventAggregator.GetEvent<ReportAddedEvent>().Subscribe(this.OnReportAdded);
Run Code Online (Sandbox Code Playgroud)

订阅ReportAddedEvent会执行两次。

您应该检查(通过在行上使用调试器和断点)是否执行多次。