C# – WebBrowser Control Focus

browsercnetwebwpf

Hopefully someone will be able to help.

I've embedded a WebBrowser Control into my C# WPF application and this works perfect with touches and mouse wheel movements (I've embedded a Google Maps page).

However as soon as I open another application then go back to my C# Application the WebBrowser Control has lost focus which then stops touches and the mouse wheel from working.

The only way I can get it working again is to TAB until the focus is back on the WebBrowser Control. I've tried setting the Focus() on the WebBrowser Control but it never seems to get the focus back.

Any Ideas?

Best Answer

Set Focusable to true before calling Focus(). default value for Focusable is false.

webBrowser1.Focusable = true;
webBrowser1.Focus();