Showing touch keyboard on custom control

淺唱寂寞╮ 提交于 2019-12-01 06:08:17

问题


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

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.

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.


回答1:


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();
}


来源:https://stackoverflow.com/questions/33437604/showing-touch-keyboard-on-custom-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!