背景:我们在触摸屏信息亭上使用屏幕键盘来允许用户输入文本。退格按钮失败,因为 System.Windows.Input.Keyboard.PrimaryDevice.ActiveSource 变为空。
代码上下文:
if (System.Windows.Input.Keyboard.PrimaryDevice.ActiveSource != null)
{
System.Windows.Input.KeyEventArgs ke =
new System.Windows.Input.KeyEventArgs(
System.Windows.Input.Keyboard.PrimaryDevice,
System.Windows.Input.Keyboard.PrimaryDevice.ActiveSource,
0,
System.Windows.Input.Key.Back);
ke.RoutedEvent = UIElement.KeyDownEvent;
System.Windows.Input.InputManager.Current.ProcessInput(ke);
}
else
{
Console.Out.WriteLine("Problemo");
}
我不能使用带有 null ActiveSource 的 KeyEventArgs,并且 System.Windows.Forms.SendKeys.SendWait("{BACKSPACE}") 也不起作用。