Note that there are some explanatory texts on larger screens.

plurals
  1. POCaliburn Micro 'Enter' Key Event
    primarykey
    data
    text
    <p>I am attempting to bind an event with Caliburn Micro and I am having some issues getting the right messages to the method. I would like to add the ability to press the 'Enter' key after changing the value in a text box and it execute the same method that the button next to is bound to. However, regardless of which key is pressed, I get the following exceptions: </p> <blockquote> <p>A first chance exception of type 'System.InvalidCastException' occurred in MyApp.exe</p> <p>A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll</p> <p>A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in WindowsBase.dll</p> </blockquote> <p>At the suggestion of another, similar question <a href="https://stackoverflow.com/questions/12714727/binding-keydown-event-silverlight">Binding KeyDown Event Silverlight</a>, I've tried using ActionExecutionContext, but to no avail.</p> <p>Here is the xaml:</p> <pre><code>&lt;TextBox Name="Threshold" Margin="5" Grid.Column="1" &gt; &lt;i:Interaction.Triggers&gt; &lt;i:EventTrigger EventName="KeyDown"&gt; &lt;cal:ActionMessage MethodName="ExecuteFilterView"&gt; &lt;cal:Parameter Value="$executionContext"/&gt; &lt;/cal:ActionMessage&gt; &lt;/i:EventTrigger&gt; &lt;/i:Interaction.Triggers&gt; &lt;/TextBox&gt; </code></pre> <p>And the method:</p> <pre><code> public void ExecuteFilterView(ActionExecutionContext context) { //Do stuff... } </code></pre> <p>I understand that I could probably save myself some headaches and simply do a standard event handler in the code behind, but this app is an exercise in MVVM and learning to utilize Caliburn.Micro, so I would like to stick with making this particular approach work.</p> <p>Am I just trying to send the wrong information from the event? Is my xaml not coded properly to get what I want? Or I have missed something else entirely?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload