What is advantage of EventAggregators?

Topics: Prism v1
Apr 18, 2009 at 6:28 AM
Hi All,
I am in newbie for Prism. Presently I am working on project developed using PRISM v1. There are more than two teams working on different modules in it. The Infrastructure and shell part is developed by a team working from different geographical location.

My question is, the infrastructure design does not have any sign of EventAggregator implementation.

For example,
To set wait cursor and to change the text in the statusbar (which is in Shell), they have written a static class (nothing to do with event aggregators). Whereas this can be done by Publishing/Subscribing event aggregators (Smart Client uses Event Brokers).

So, could anyone tell me, which is the best and good way to implement?

And also can anyone directly me to the release notes of Prism v2?
Apr 19, 2009 at 7:15 PM
Suppose your shell had a StatusBar region.  Also suppose that when shell loads it loads an infrastructure module.  Also suppose that your infrastructure module has a Status Bar Module or Status Bar Controller, and a Status Bar View.  Also assume that your infrastructure project has a NotifyStatusBarEvent.

The benefit of using event aggregator would be that the Status Bar View could subscribe to the NotifyStatusBarEvent and all of the other modules, i.e. Module A, Module B, Module C could reference the infrastructure module and publish the NotifyStatusBarEvent.

Your module developers dont need to know anything, except that when they want to update the status bar, they simply publish the NotifyStatusBarEvent.  The Status Bar Controller / Presenter / Model will handle setting the text of the status bar, setting the mouse global override, disabling other items in the shell, etc.
Apr 21, 2009 at 10:35 PM

Hi venki5star,


The purpose of the EventAggregator is to enable modules to publish/subscribe to events in a decoupled way (without the publisher nor the subscriber to reference each other). This is pretty much the same concept of the Event Broker in CAB.

In most general scenarios the infrastructure project does not need any reference to the EventAggregator as it is provided directly by CAL. The Infrastructure project usually has the interfaces / implementations for the published events (subclasses of EventBase or CompositePresentationEvent<TPayload>).


It is a recommended practice to use .net events instead of EventAggregator inside modules when other modules don’t need to handle the event. You might find the following articles from the documentation useful:

·         Event Aggregator (Technical concept)

·         Communication (Technical concept)

·         Event Aggregation QuickStart

·         How to: Create and Publish Events

·         How to: Subscribe and Unsubscribe to Events


You mentioned a static class. A static class is usually used to create globally available command. You will find more information on this in the How to: Create Globally Available Commands.


You can find the MSDN landing page for Prism v2 at: Composite Application Guidance for WPF and Silverlight. This is the released version, so there are not any release notes. (The release notes for Prism-v1 were meant to notify of the latest changes between drops).


Hope it helps!


Matias Bonaventura


Apr 22, 2009 at 3:48 AM
This is too good and easy to understand. Thank for spending your time for me.

Venkatesh Mookkan