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

New Post: Prism EventAggregator Callback to the publisher

$
0
0
Hi,

Based on my understanding of your question, I believe there are two possible approaches for your scenario:

1) Create a new CompositePresentationEvent and subscribe your LeftControl to it to handle the refresh. Then, after the RightControl finishes handling the first event, it could publish a second one with the EventAggregator as a callback.

2) Create a new class with both the parameter you are passing with your CompositePresentationEvent and a callback event:
public class MyClass
{
    public ParameterType parameter;
    public event MyCallbackEvent callback;
}
Then, in your LeftControl, you could create an instance of this class, where you would set the parameter to be passed and subscribe to the callback event. After publishing the CompositePresentationEvent with this instance as the payload, the subscribed RightControl would receive the instance in its handler. So, after handling the published event, the RightControl could simply raise the callback event passed as a method of executing a callback in the LeftControl :
// In LeftControl
MyClass c = new MyClass();
c.parameter = // The original parameter
c.callback += // The method of the LeftControl that will be invoked as the callback
this.eventAggregator.GetEvent<MyCompositeEvent>().Publish(c);

// In RightControl
public void EventHandler(MyClass c)
{
    // Do work...
    c.callback.Invoke();
}
Hope this helps,

Federico Martinez
http://blogs.southworks.net/fmartinez

Viewing all articles
Browse latest Browse all 1878

Latest Images

Trending Articles



Latest Images

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