wpf 网页浏览器控制焦点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19007341/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WebBrowser Control Focus
提问by Strikeforce
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).
我已将 WebBrowser 控件嵌入到我的 C# WPF 应用程序中,这与触摸和鼠标滚轮移动完美配合(我已嵌入 Google 地图页面)。
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.
但是,一旦我打开另一个应用程序然后返回到我的 C# 应用程序,WebBrowser 控件就会失去焦点,然后停止触摸和鼠标滚轮的工作。
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.
我让它再次工作的唯一方法是 TAB,直到焦点重新回到 WebBrowser 控件上。我试过在 WebBrowser 控件上设置 Focus(),但它似乎永远无法获得焦点。
Any Ideas?
有任何想法吗?
采纳答案by Kurubaran
Set Focusable to truebefore calling Focus(). default value for Focusable is false.
true在调用之前将 Focusable 设置为Focus()。Focusable 的默认值为false。
webBrowser1.Focusable = true;
webBrowser1.Focus();

