title: Command Executs when Enter Key is Pressed Twice
body: <p>I have a combobox. I have some input bindings on it as follows:</p>
  
  <pre><code>&lt;ComboBox .........&gt;
  
      &lt;ComboBox.InputBindings&gt;
          &lt;KeyBinding Command="{Binding DataContext.DeleteUnwantedOrderItemTransactionCommand, 
                                        RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type coreUI:UserControlViewBase}}}"
                      Gesture="Return" /&gt;
          &lt;KeyBinding Command="{Binding DataContext.DeleteUnwantedOrderItemTransactionCommand, 
                                        RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type coreUI:UserControlViewBase}}}"
                      Gesture="Tab" /&gt;
      &lt;/ComboBox.InputBindings&gt;
  
  &lt;/ComboBox&gt;
  </code></pre>
  
  <p>In ViewModel I have RelayCommands as Follows:</p>
  
  <pre><code>public RelayCommand DeleteUnwantedOrderItemTransactionCommand { get; set; }
  public RelayCommand AddNewOrderItemTransactionCommand { get; set; }
  
  public OrderViewModel(IEventAggregator _eventAggregator)
  {
      eventAggregator = _eventAggregator;
  
      DeleteUnwantedOrderItemTransactionCommand = new RelayCommand(DeleteUnwantedOrderItemTransaction);
      AddNewOrderItemTransactionCommand = new RelayCommand(AddNewOrderItemTransaction);
  }
  
  protected void DeleteUnwantedOrderItemTransaction(object obj)
  {
      if (!(SelectedOrderItemTransaction.ItemId &gt; 0))
      {
          NewOrder.OrderItemTransactions.Remove(SelectedOrderItemTransaction);
      }
  
      if (NewOrder.OrderItemTransactions.Count == 0)
      {
          NewOrder.OrderItemTransactions.Add(new OrderItemTransaction());
      }
  
      eventAggregator.GetEvent&lt;ChangeFocusToNextUIElementEvent&gt;().Publish(true);
  }
  
  protected void AddNewOrderItemTransaction(object obj)
  {
      if (SelectedOrderItemTransaction == NewOrder.OrderItemTransactions.Last())
          NewOrder.OrderItemTransactions.Add(new OrderItemTransaction());
  
      eventAggregator.GetEvent&lt;ChangeFocusToNextUIElementEvent&gt;().Publish(true);
  }
  </code></pre>
  
  <p>Then in CodeBehind:</p>
  
  <pre><code>public OrderView(OrderViewModel _viewModel, IEventAggregator _eventAggregator)
  {
      InitializeComponent();
      this.DataContext = _viewModel;
      _eventAggregator.GetEvent&lt;ChangeFocusToNextUIElementEvent&gt;().Subscribe(MoveToNextUIElement);
  }
  
  void MoveToNextUIElement(bool obj)
  {
      // Gets the element with keyboard focus.
      UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;
  
      if (elementWithFocus != null)
      {
          elementWithFocus.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
      }
  }
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>I have specified in the InputBindings that when user Presses <kbd>Enter</kbd> or <kbd>Tab</kbd>, I want to execute a RelayCommand and on completion of execution that Command, I want to Move Focus to the next element.</p>
  
  <p>In this case:</p>
  
  <p>When I Press <kbd>Tab</kbd> everything works fine. The Command is executed and focus moves to next Element. </p>
  
  <p>But when I press <kbd>Enter</kbd> 1<sup>st</sup> time, The Item is selected in the ComboBox. Command Does not Fire and So, Focus does not move to the next element. When I press <kbd>Enter</kbd> 2<sup>nd</sup> the Command executes and focus moves to the next Control as expected.</p>
  
  <p><strong>But I don't want this behavior. I want to Execute Command and Move Focus to the next element when 1<sup>st</sup> time <kbd>Enter</kbd> is pressed.</strong></p>