解决cefSharp的wpf版本里无法输入中文的问题
chromeBrowser = new ChromiumWebBrowser(Models.StaticList.ApiUrl + "/Home/Menu"); chromeBrowser.MenuHandler = new MenuHandler(); chromeBrowser.HorizontalAlignment = HorizontalAlignment.Stretch; chromeBrowser.VerticalAlignment = VerticalAlignment.Stretch; chromeBrowser.PreviewTextInput += (obj, args) => { foreach (var character in args.Text) { // 把每个字符向浏览器组件发送一遍 chromeBrowser.GetBrowser().GetHost().SendKeyEvent((int)WM.CHAR, (int)character, 0); } // 不让cef自己处理 e.Handled = true; }; chromeBrowser.LostFocus += ChromeBrowser_LostFocus; chromeBrowser.GotFocus += ChromeBrowser_GotFocus; chromeBrowser.WpfKeyboardHandler = new CefSharp.Wpf.Experimental.WpfImeKeyboardHandler(chromeBrowser);
最后一行,加粗的部分加上后就解决了
来源:https://github.com/cefsharp/CefSharp/issues/1262