I am trying to simulate a key press in a button event. I can use the code below to simulate some keys such as Backspace, but the Enter is not working.
What am I doing wrong?
private void btnEnter_Click(object sender, RoutedEventArgs e)
{
tbProdCode.Focus();
KeyEventArgs ke = new KeyEventArgs(
Keyboard.PrimaryDevice,
Keyboard.PrimaryDevice.ActiveSource,
0,
Key.Enter)
{
RoutedEvent = UIElement.KeyDownEvent
};
InputManager.Current.ProcessInput(ke);
}