Event aggregator and ViewModels communication

Topics: Prism v2 - Silverlight 2, Prism v2 - Silverlight 3
Sep 15, 2009 at 2:42 PM


I'm developing an application, using Silverlight Navigation Framework, the MVVM pattern, and some features provided by Prism (commands).

In order ViewModels to communicate each other, I'm using Prism Event Aggregator so, each time I want to "exchange" parameters between methods belonged to different ViewModel or "inform" that an event is occured, I publish/subscribe an event. Is this a right approach to the problem?

Moreover, my application is composed by about 90 Page, and the communication between the ViewModels of these pages is not very hight, because all these Pages exchange data (throught WCF services) with the model on the server. The problem is that I have very often popup and wizard that are opened in these page. So, the communication is very high between the view models of the Page and the ChildWindow. In this case, is the right approach to use eventAggregator for this type of communication? I have read that the right pattern is the mediator one. The Event Aggregator implement this pattern?

Are there other features of Prism or other solution that I can access in order to make this communication simpler?

Thank you very much

Sep 15, 2009 at 3:41 PM

I find that sharing the View Model simplifies life greatly, particularly when working with WCF Services where the various views are sharing the data, e.g., Summary and Detail information.   Note: When I have multiple views sharing a common View Model (concern) I'll register it as a singleton.