2 Views communication best practice CAB

Topics: CAB & Smart Client Software Factory
Mar 29, 2007 at 6:17 PM
I have 2 views each in their own WorkItem. (CAB only, C#)

These two WorkItems are 'brothers' in the same RootWorkItem.

What's the best way to communicate that "The user chose ABC" in view 1 to view 2?

Would EventPublication/Subscription be the best way? Or use State?
Coordinator
Mar 29, 2007 at 7:24 PM
Hi Ian,
If the View 1 is responsible for managing the selection of some items and does not care what the user does in View 2 (it probably displays the details for the item selected in View 1, right?), then I think the best way to communicate these two views is with the EventPublication/Subscription approach. But keep in mind that this decouples the event publication from the subscription entirely, so there will not be any feedback from View 2, as you should not use the EventArgs to pass data back to the publisher. Check out Mario Szpuszta's article for more info on this.
If that would be the case, and you need to pass data back to the caller, you should definitively use the Command pattern (this is also explaned very clearly in the previous article).
What I do recommend whatever is your case, is that you do not use State at all… definitely not for communication between workitems.

Please let me know if you have any more doubts,
Julián Domínguez
http://staff.southworks.net/blogs/jdominguez