This project has moved. For the latest updates, please go here.

[CommandHandler] Attribute with DevExpress

Feb 18, 2008 at 4:27 PM
I am trying to use the CAB CommandHandler attribute with the DevExpress Bars ItemClickEventArgs to get information about which menu item was clicked but I get an exception stating "Error binding to target method."
The exception goes away if I change the ItemClickEventArgs to EventArgs (from the System namespace.) However, when that is done, I lose my ItemClicked info... I am using the CABDevexpress contribution and I know that there are adapters in play for the Bars object (BarsUIAdapter.)

The code that cuases the exception to be thrown looks like this:

public void OnEdit(object sender, ItemClickEventArgs e)
BarCheckItem item = e.Item as BarCheckItem;
if (item == null) return;
if (item.Caption == "Cut")

Any suggestion you may have would be appreciated...


Feb 19, 2008 at 1:09 PM
Edited Feb 19, 2008 at 1:12 PM
Exactly, say goodbye to your ItemClickEventArgs! ;-)

You've got the wrong idea about how to use CommandHandler .
The CommandHandler is a generic command issuing mechanism. It's just a trigger and you can't pass any information around with it (the EventArgs gets discarded anyway).

Besides, it doesn't make sense to introduce something specific to a particular control (like ItemClickEventArgs). A single command may be attached to more than one event source, so expecting ItemClickEventArgs would be asking for something to go bang!

If you want to pass information around with your event, then you have to use EventBroker.
Feb 19, 2008 at 1:26 PM
Makes sense. Thanks for your response!