当前位置: 移动技术网 > IT编程>开发语言>.net > WPF 禁用TextBox的触摸后自动弹出虚拟键盘

WPF 禁用TextBox的触摸后自动弹出虚拟键盘

2018年12月21日  | 移动技术网IT编程  | 我要评论

保卫萝卜挑战28,洪荒之孔宣明道,吴阿敏42式太极拳

前言 & 问题

如下截图,textbox,在触摸点击后,会自动弹出windows的虚拟键盘。

如何,禁用键盘的自动弹出?

调用虚拟键盘

通过调用taptip.exe或者osk.exe,主动弹出虚拟键盘

详细调用可参考:

如何禁用键盘的弹出

textbox在触摸点击后,会自动弹出虚拟键盘,是因为在控件中作了封装。

--textbox中详细tabtip.exe封装看了会,没找到

处理方案:重写textbox的方法oncreateautomationpeer,返回一个uielementautomationpeer而不是automationpeer。

可能原因:textbox自定义实现中返回的是automationpeer,而uielementautomationpeer继承automationpeer,重写了相关键盘属性。

猜测与haskeyboardfocuscore属性有关。

直接复制如下代码:

 1     /// <summary>
 2     /// 禁用自动弹出虚拟键盘的textbox控件
 3     /// </summary>
 4     public class textboxnoautokeyboard : textbox
 5     {
 6         protected override automationpeer oncreateautomationpeer()
 7         {
 8             return new frameworkelementautomationpeer(this);
 9         }
10     }

 以上参考自:【stackoverflow】“hide” text box from automatic win10 keyboard showing

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网