I am adding a custom shortcut (F11) to the WPF Webrowser using Webview.Shortcuts. This works perfectly except when the keyboard focus is in another WPF control (e.g. textbox), then the webview command handler is executed twice rather than the expected once.
I have a simple WPF app with a webbrowser and a textbox. When the keyboard focus is in the textbox, the F11 command handler fires twice.
Code: C#
public partial class MainWindow : Window
{
private int command;
public MainWindow()
{
InitializeComponent();
command = CommandIds.RegisterUserCommand("MyCommand");
webview.Shortcuts = new[] { new Shortcut(command, KeyCode.F11) };
webview.Command += webview_Command;
}
private void webview_Command(object sender, CommandEventArgs e)
{
if (e.CommandId == command && !e.Handled)
{
textbox.Text += "a";
e.Handled = true;
}
}
}