title: Capturing the Enter key in a TextBox
body: <p>In my WPF view, I am trying to tie an event to the Enter key as follows:</p>
  
  <pre><code>&lt;TextBox Width="240" VerticalAlignment="Center" Margin="2" Text="{Binding SearchCriteria, Mode=OneWayToSource}"&gt;
    &lt;TextBox.InputBindings&gt;
        &lt;KeyBinding Key="Enter" Command="{Binding EnterKeyCommand}"/&gt;
        &lt;KeyBinding Key="Tab" Command="{Binding TabKeyCommand}"/&gt;
    &lt;/TextBox.InputBindings&gt;
  &lt;/TextBox&gt;
  </code></pre>
  
  <p>This code works and my EnterKeyCommand fires when the users presses the Enter key. However, the problem is that when the event fires, WPF hasn't yet bound the text in the textbox to 'SearchCriteria'. So when my event fires, the contents of 'SearchCriteria' is blank. Is there a simple change I can make in this code so that I can get the contents of the textbox when my EnterKey command fires?</p>