询问者
自定义控件如何直接获取键盘(外置键盘和触摸键盘)的输入内容

问题
-
现在在开发一个win8/rt平台的类似远程桌面的软件,用Image控件作为显示界面。现在的问题是无法直接获取键盘的输入内容,所以暂时的做法是先把内容输入到textbox上,然后再把字符串发送到服务器。
http://code.msdn.microsoft.com/windowsapps/Touch-keyboard-sample-43532fda 这例子提供了一个简单的demo,但是似乎不起作用,不知道是不是我的使用方式有问题。
全部回复
-
Hi, caozhongqian
Input: Touch keyboard 这个sample是起作用的,请看这个sample的CustomControl1.xaml.cs里面的OnKeyDown函数:
protected override void OnKeyDown(KeyRoutedEventArgs e) { this.myTextBlock.Text = "A key was pressed @ " + DateTime.Now.ToString(); }
它并没有获取当前按下的键盘的内容,您可以在里面获取:
protected override void OnKeyDown(KeyRoutedEventArgs e) { this.myTextBlock.Text = e.Key+"A key was pressed @ " + DateTime.Now.ToString(); }
其中e.key就是获取当前的按键内容。
您可以参考一下以下链接
http://msdn.microsoft.com/en-us/library/windows/apps/hh868246.aspx
祝您好运!
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later. -
Hi,
sample的CustomControl1的xaml里面是定义了一个TextBlock 控件,如果您改为TextBox控件的话应该是会支持中文的输入的。
您具体想实现什么呢?能否详细的描述一下!
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.