热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

为WindowsStore应用定制虚拟键盘-CustomizedvirtualkeyboardforWindowsStoreApp

SinceMicrosoftdoesntallowtoreplacethesystemsvirtualkeyboard,Ivedevelopedacustomvirt

Since Microsoft doesn't allow to replace the system's virtual keyboard, I've developed a custom virtual keyboard as a UserControl to be used inside my Windows Store App. My current problem is that the default virtual keyboard always pops up whenever a user taps a TextBox.

由于微软不允许替换系统的虚拟键盘,我开发了一个自定义虚拟键盘作为用户控件,可以在我的Windows Store应用程序中使用。

I've been searching for a solution to this problem since yesterday, but I couldn't solve it. My almost successful attempt was developing a TextBox with a transparent Canvas over it. When the user taps the Canvas, the focus is programatically transferred to the TextBox and my custom virtual keyboard is instantiated. However, if no physical keyboard is connected to the tablet, the system keyboard also pops up with this approach (over my custom keyboard).

从昨天起我一直在寻找解决这个问题的办法,但是我没有办法。我几乎成功的尝试是开发一个带有透明画布的文本框。当用户轻击画布时,焦点被程序化地转移到文本框中,我的自定义虚拟键盘被实例化。然而,如果没有物理键盘连接到平板电脑上,系统键盘也会弹出这种方式(通过我的自定义键盘)。

The main reason why I want to use a TextBox is because that way I can preserve and use the already implemented caret function, but it is not mandatory.

我想使用文本框的主要原因是,这样我可以保存和使用已经实现的插入符号函数,但它不是强制性的。

Any input will be helpful, thanks.

任何意见都可以,谢谢。

1 个解决方案

#1


0  

There are a couple of things you could do:

你可以做以下几件事:

There are events for when the keyboard shows up, check those and see if you can prevent it.

当键盘出现时,会出现一些事件,检查这些事件,看看是否可以阻止它。

You could implement a custom TextBox that suppresses OnPointerPressed event so that the TextBox is never focused. There are a couple of other things you'll need to do (such as prevent tabbing into it giving focus by setting IsTabStop=false.

您可以实现一个自定义文本框,该文本框抑制OnPointerPressed事件,这样文本框就不会集中。您还需要做一些其他的事情(例如通过设置IsTabStop=false来防止将焦点设置为it)。

You could implement a custom TextBox from the ground up (that looks and acts like a TextBox).

您可以从头开始实现一个自定义文本框(它的外观和功能类似于一个文本框)。

I think the second option is the easiest and most interesting option to try.

我认为第二个选择是最简单和最有趣的选择。

Edit: You could also give your TextBox a DependencyProperty that you set the current Page to via bindings. In the TextBox's OnGotFocus event, set the visual state to "CustomFocus" (or whatever you call it), then call Page.Focus();

编辑:您还可以给您的文本框一个DependencyProperty,您可以通过绑定将当前页面设置为DependencyProperty。在文本框的OnGotFocus事件中,将视觉状态设置为“CustomFocus”(或其他名称),然后调用Page.Focus();


推荐阅读
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • 本文介绍了C#中数据集DataSet对象的使用及相关方法详解,包括DataSet对象的概述、与数据关系对象的互联、Rows集合和Columns集合的组成,以及DataSet对象常用的方法之一——Merge方法的使用。通过本文的阅读,读者可以了解到DataSet对象在C#中的重要性和使用方法。 ... [详细]
  • 本文详细介绍了使用C#实现Word模版打印的方案。包括添加COM引用、新建Word操作类、开启Word进程、加载模版文件等步骤。通过该方案可以实现C#对Word文档的打印功能。 ... [详细]
  • C#多线程解决界面卡死问题的完美解决方案
    当界面需要在程序运行中不断更新数据时,使用多线程可以解决界面卡死的问题。一个主线程创建界面,使用一个子线程执行程序并更新主界面,可以避免卡死现象。本文分享了一个例子,供大家参考。 ... [详细]
  • C语言的经典程序有哪些
    本篇内容介绍了“C语言的经典程序有哪些”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何 ... [详细]
  • KeyboardInterruptHooksafelyusingKINTERRUPTBy:chpiehttp:www.rootkit.comnewsread.php ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • HDU 2372 El Dorado(DP)的最长上升子序列长度求解方法
    本文介绍了解决HDU 2372 El Dorado问题的一种动态规划方法,通过循环k的方式求解最长上升子序列的长度。具体实现过程包括初始化dp数组、读取数列、计算最长上升子序列长度等步骤。 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • 《数据结构》学习笔记3——串匹配算法性能评估
    本文主要讨论串匹配算法的性能评估,包括模式匹配、字符种类数量、算法复杂度等内容。通过借助C++中的头文件和库,可以实现对串的匹配操作。其中蛮力算法的复杂度为O(m*n),通过随机取出长度为m的子串作为模式P,在文本T中进行匹配,统计平均复杂度。对于成功和失败的匹配分别进行测试,分析其平均复杂度。详情请参考相关学习资源。 ... [详细]
  • 本文介绍了如何使用C#制作Java+Mysql+Tomcat环境安装程序,实现一键式安装。通过将JDK、Mysql、Tomcat三者制作成一个安装包,解决了客户在安装软件时的复杂配置和繁琐问题,便于管理软件版本和系统集成。具体步骤包括配置JDK环境变量和安装Mysql服务,其中使用了MySQL Server 5.5社区版和my.ini文件。安装方法为通过命令行将目录转到mysql的bin目录下,执行mysqld --install MySQL5命令。 ... [详细]
  • 导出功能protectedvoidbtnExport(objectsender,EventArgse){用来打开下载窗口stringfileName中 ... [详细]
  • 本文介绍了在iOS开发中使用UITextField实现字符限制的方法,包括利用代理方法和使用BNTextField-Limit库的实现策略。通过这些方法,开发者可以方便地限制UITextField的字符个数和输入规则。 ... [详细]
  • 在C#中,使用关键字abstract来定义抽象类和抽象方法。抽象类是一种不能被实例化的类,它只提供部分实现,但可以被其他类继承并创建实例。抽象类可以用于类、方法、属性、索引器和事件。在一个类声明中使用abstract表示该类倾向于作为其他类的基类成员被标识为抽象,或者被包含在一个抽象类中,必须由其派生类实现。本文介绍了C#中抽象类和抽象方法的基础知识,并提供了一个示例代码。 ... [详细]
  • Ihavebeenworkingwithbufferingafileonmylocaldrivetoparseandobtaincertaindata.Forte ... [详细]
author-avatar
木又的思念_740
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有