Using event args with ActionMessage?

Feb 13, 2011 at 12:57 AM

I'm trying to use the AutoComplete box and override the Populating event in order to perform my own custom code. Placing custom code in the AutoCompleteBox requires you to set e.Cancel = true. e being the PopulatingEventArgs. How can I do this using Micro? 

Feb 13, 2011 at 1:06 AM

Just tried this and no luck:

cal:Message.Attach="[Event Populating] = [Action SearchPopulating($eventArgs)]

I get the error: No target found for method SearchPopulating. Here's my method:

public void SearchPopulating(object sender, PopulatingEventArgs e){
            e.Cancel = true;

Feb 13, 2011 at 2:19 AM

The signatures don't match. Remove the 'sender' parameter from your method or add another parameter of $this before $eventArgs to your action.

Feb 13, 2011 at 5:20 AM

Thanks, that worked. Is that the only way to pass the args? There is no way using the EventTrigger method?

Feb 13, 2011 at 3:55 PM

I'm not sure I understand the question.

Feb 13, 2011 at 8:43 PM

Well so I found that I should be able to do this:

<i:EventTrigger EventName="ItemDroppedOnTarget">
         <cal:ActionMessage MethodName="UserDropped">
         <cal:Parameter Value="$this" />
         <cal:Parameter Value="$eventArgs"/>
but in my event:
public void UserDropped(object sender, DragEventArgs e) {
            var rawr = "";

sender == "$this" and e == null... What am I missing?

Feb 13, 2011 at 9:05 PM

You cannot use $this inside and explicit parameter. I can only be used from Message.Attach. I might be able to change that. But, that is why sender comes through as the string. It's not interpreted as a special value in that context. Now, I don't know for sure why your event args are null. But, if I had to guess, it would be that the type of event args is not actually DragEventArgs. The framework is attempting an "as" cast which is failing and null is being passed. That's just a guess though.