Reputation: 37905
I have a textbox with the following:
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyUp" >
<cal:ActionMessage MethodName="OnKeyUp" >
<cal:Parameter Value="$eventArgs"/>
</cal:ActionMessage>
</i:EventTrigger>
If I run this, an error message is produced saying "No target found for Method OnKeyUp." If I remove the parameter from the message, and the method, then it runs fine.
This is the method.
public void OnKeyUp(object sender, KeyEventArgs e) {
MessageBox.Show(e.Key.ToString());
}
I don't see what the issue is.
Upvotes: 5
Views: 7148
Reputation: 34349
Your view model method takes two parameters, but you're only passing one.
Either change your view to pass the $source
:
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyUp">
<cal:ActionMessage MethodName="OnKeyUp" >
<cal:Parameter Value="$source" />
<cal:Parameter Value="$eventArgs" />
</cal:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
or change your method to just take the event arguments:
public void OnKeyUp(KeyEventArgs e) { ... }
You could also use the much nicer shorthand:
<TextBox cal:Message.Attach="[Event KeyUp] = [Action OnKeyUp($source, $eventArgs)]" />
Upvotes: 11