在自定义控件上显示触摸键盘 [英] Showing touch keyboard on custom control

查看:32
本文介绍了在自定义控件上显示触摸键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

触摸键盘示例展示了一种方法开发人员通知系统在用户触摸自定义控件时显示触摸键盘 [可能在平板电脑模式下].有人指出

The Touch keyboard sample shows a way for developers to inform the system to display touch keyboard as user touch a custom control [probably in tablet mode]. It was remarked that

在 PC 上,您可以通过实现 TextPattern 提供程序接口 (ITextProvider) 和 ValuePattern 提供程序接口 (IValueProvider) 来请求自定义控件的触摸键盘显示.手机不支持.

On the PC, you can request that the touch keyboard display for a custom control by implementing the TextPattern provider interface (ITextProvider) and the ValuePattern provider interface (IValueProvider). Not supported on Phone.

有谁知道如何在 Windows 10 手机上实现同样的功能?作为旁注,我想知道为什么台式机和手机之间存在如此大的差异.我认为 Continuum 适用于任何场景.

Does anyone know how to achieve the same thing on Windows 10 phones? As a side note, I wonder why there is such a disparity between desktop and phone. I thought Continuum works in any scenario.

推荐答案

On phone you I think you should be able to do use InputPaneCoreWindow.CharacterReceived 事件.订阅该事件以了解单击了哪个键并使用 InputPane 的 方法显示/隐藏键盘.显示按键的示例如下所示:

On phone you I think you should be able to do use InputPane and CoreWindow.CharacterReceived event. Subscribe to the event to know what key has been clicked and show/hide keyboard with InputPane's methods. A sample showing keystrokes can look like this:

public MainPage()
{
    this.InitializeComponent();
    Window.Current.CoreWindow.CharacterReceived += (s, e) =>
    {
        Debug.WriteLine($"Character received -> {e.KeyCode}");
        e.Handled = true;
    };
}

private void Button_Click(object sender, RoutedEventArgs e)
{
    InputPane pane = InputPane.GetForCurrentView();
    pane.TryShow();
}

这篇关于在自定义控件上显示触摸键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆