0

I am trying to stop F5 on my WebBrowser control in WPF. I have came across this solution. but i am unable to find WebBrowserShortcutsEnabled for WebBrowser control. Is there an equivalent for WebBrowserShortcutsEnabled or am i missing something.

Community
  • 1
  • 1
Abin
  • 2,868
  • 1
  • 23
  • 59

1 Answers1

2

You may prevent keyboard events from reaching the WebBrowser control in WPF by handling its PreviewKeyDown event. This will allow you to override the behavior, as well as do nothing for specific key strokes. Handling the Backspace key might be harder, since it might prevent user input in text boxes.

void Browser_OnPreviewKeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.F5)
    {
        e.Handled = true;
    }
}

Xaml:

<WebBrowser PreviewKeyDown="Browser_OnPreviewKeyDown"></WebBrowser>
Bas
  • 26,772
  • 8
  • 53
  • 86