Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Pass two or more parameters via EventAggregator

$
0
0
Hi,

As far as I know, when publishing an event you can only pass one parameter of the same type as the event's payload. For example, if you define a MyEvent doing something like this:
public class MyEvent : CompositePresentationEvent< MyParameterClass >
It means you can pass an object of type MyParameterClass when publishing the event.

However, this gives you a lot of flexibility as the MyParameterClass could be as simple or as complex as you want. Taking this into account, a possible approach to pass several parameters could be encapsulate those parameters in a single one used to contain them:
parameters.Parameter1 = parameter1;
parameters.Parameter2 = parameter2;
eventAggregator.GetEvent<MyEvent>().Publish(parameters);
Regards,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Viewing all articles
Browse latest Browse all 1878


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>