Events handling

Topics: CAB & Smart Client Software Factory
Jan 4, 2007 at 4:11 PM
Hi, I am very new to Cab and SCSF. I just wanderring which is the correct way to handle UI events in Cab.

I've created a drag and drop treeview, and the normal way of handling event would be:

-- this.treeView1.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeView_DragDrop);
-- private void treeView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { handling code }

Would it be different in Cab since the tree drag and drop event would change the actual tree and could be used by other smart parts.

Many thanks.

Jan 5, 2007 at 4:24 AM
CAB doesn't really care much about UI elements however you could just follow the MVP pattern for this. There's various ways to hook up the view and presenter together (presenter subscribing to views events through delegates, etc.) but generally you would pass on whatever information to the presenter from your view with your view talking to the controls it knows about (in this case the tree control) and the presenter doing whatever you want with it (publish the information to another view for example via the EventBroker).
Jan 6, 2007 at 4:53 PM
Implementing UI elements handling code directly(or delegation) to the view isnt very neat, but at least I know it will work. However, if I use MVP pattern, it would require passing alot of information from the view to presenter. For this case, it seems to be trivial. However with more complex scenarios, things will get very messy.

I havent been able to find any examples on complex UI elements handling through MVP. If you have any, please enlight me with them.
Jan 6, 2007 at 7:55 PM
I have found that handling the event and the UI related changes in the view, and then data or object related info in the presenter. I expose objects through properties in the presenter, so the View can bind directly to them, change them, etc., thus minimizing the passing of info around...