Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Tabtip和InputScope-显示数字键盘_C#_Wpf_Keyboard - Fatal编程技术网

C# Tabtip和InputScope-显示数字键盘

C# Tabtip和InputScope-显示数字键盘,c#,wpf,keyboard,C#,Wpf,Keyboard,我有一个平板电脑,它必须运行带有数字输入字段的应用程序。但是,我在让windows键盘(TabTip.exe)弹出显示默认数字键盘时遇到问题 当点击文本字段时,键盘需要自动弹出 通过在TextBox事件处理程序中运行TabTip.exe,我设法让它在每个字段上显示键盘,但它显示的是正常的键盘布局。这是对这个问题的回答: 我在下一页读到,您可以使用文本框的“InputScope”属性指定它应该是数字键盘 比如说 然而,这并没有效果,它仍然以常规布局弹出。此外,我发现很难相信InputScope会

我有一个平板电脑,它必须运行带有数字输入字段的应用程序。但是,我在让windows键盘(TabTip.exe)弹出显示默认数字键盘时遇到问题

当点击文本字段时,键盘需要自动弹出

通过在TextBox事件处理程序中运行TabTip.exe,我设法让它在每个字段上显示键盘,但它显示的是正常的键盘布局。这是对这个问题的回答:

我在下一页读到,您可以使用文本框的“InputScope”属性指定它应该是数字键盘

比如说

然而,这并没有效果,它仍然以常规布局弹出。此外,我发现很难相信InputScope会将自己传递到TabTip.exe进程的执行过程中,而不以某种方式将它们连接起来

我也遇到过这样的情况:这建议在每次调用TabTip.exe之前编辑注册表,但这看起来非常混乱,在Windows 10中显然不可靠


难道没有命令行参数或可以传递给它的东西吗?

我找到了答案,多亏了它,我才找到了答案

所以基本上我走错了方向

正确的方法是:添加对
InputPanelConfigurationLib.dll
UIAutomationClient.dll的引用

然后禁用墨水输入

using System; 
using System.Reflection; 
using System.Windows.Input; 

namespace ModernWPF.Win8TouchKeyboard.Desktop 
{ 
    public static class InkInputHelper 
    { 
        public static void DisableWPFTabletSupport() 
        { 
            // Get a collection of the tablet devices for this window.   
            TabletDeviceCollection devices = System.Windows.Input.Tablet.TabletDevices; 

            if (devices.Count > 0) 
            { 
                // Get the Type of InputManager. 
                Type inputManagerType = typeof(System.Windows.Input.InputManager); 

                // Call the StylusLogic method on the InputManager.Current instance. 
                object stylusLogic = inputManagerType.InvokeMember("StylusLogic", 
                            BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, 
                            null, InputManager.Current, null); 

                if (stylusLogic != null) 
                { 
                    //  Get the type of the stylusLogic returned from the call to StylusLogic. 
                    Type stylusLogicType = stylusLogic.GetType(); 

                    // Loop until there are no more devices to remove. 
                    while (devices.Count > 0) 
                    { 
                        // Remove the first tablet device in the devices collection. 
                        stylusLogicType.InvokeMember("OnTabletRemoved", 
                                BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, 
                                null, stylusLogic, new object[] { (uint)0 }); 
                    } 
                } 
            } 
        } 
    } 
} 
MainWindow.xaml.cs

public MainWindow() 
{ 
    InitializeComponent(); 

    // Disables inking in the WPF application and enables us to track touch events to properly trigger the touch keyboard 
    InkInputHelper.DisableWPFTabletSupport(); 

    this.Loaded += MainWindow_Loaded; 
} 

private void MainWindow_Loaded(object sender, RoutedEventArgs e) 
{ 

    System.Windows.Automation.AutomationElement asForm = 
        System.Windows.Automation.AutomationElement.FromHandle(new WindowInteropHelper(this).Handle); 


    InputPanelConfigurationLib.InputPanelConfiguration inputPanelConfig = new InputPanelConfigurationLib.InputPanelConfiguration(); 
    inputPanelConfig.EnableFocusTracking(); 
} 
瞧,选择一个文本框会调用键盘。但是,现在,它关注的是
InputScope
,如果我设置为
Number
,则会显示数字键盘

public MainWindow() 
{ 
    InitializeComponent(); 

    // Disables inking in the WPF application and enables us to track touch events to properly trigger the touch keyboard 
    InkInputHelper.DisableWPFTabletSupport(); 

    this.Loaded += MainWindow_Loaded; 
} 

private void MainWindow_Loaded(object sender, RoutedEventArgs e) 
{ 

    System.Windows.Automation.AutomationElement asForm = 
        System.Windows.Automation.AutomationElement.FromHandle(new WindowInteropHelper(this).Handle); 


    InputPanelConfigurationLib.InputPanelConfiguration inputPanelConfig = new InputPanelConfigurationLib.InputPanelConfiguration(); 
    inputPanelConfig.EnableFocusTracking(); 
}