2017-07-16 23 views
0

有TextBox和自定义键盘。当TextBox必须获得焦点时,我需要禁用输入窗格。我尝试了显示和焦点事件的TryHide方法。如何在UWP移动应用程序中禁用TextBox的输入窗格?

InputPane.GetForCurrentView().TryHide(); 

但它是一个非常糟糕的工作解决方案,因为InputPane是当用户在文本框录音闪烁。然后我发现在文档中更改输入策略的可能性CoreText​Input​Pane​Display​Policy但是文档没有解释如何应用此策略。 使用TextBlock不适合我,因为我需要使用光标操作并选择文本。这个问题有没有很好的解决方案?

回答

4

微软的代码示例演示了here

 // Create a CoreTextEditContext for our custom edit control. 
     CoreTextServicesManager manager = CoreTextServicesManager.GetForCurrentView(); 
     _editContext = manager.CreateEditContext(); 

     // Get the Input Pane so we can programmatically hide and show it. 
     _inputPane = InputPane.GetForCurrentView(); 

     // For demonstration purposes, this sample sets the Input Pane display policy to Manual 
     // so that it can manually show the software keyboard when the control gains focus and 
     // dismiss it when the control loses focus. If you leave the policy as Automatic, then 
     // the system will hide and show the Input Pane for you. Note that on Desktop, you will 
     // need to implement the UIA text pattern to get expected automatic behavior. 
     _editContext.InputPaneDisplayPolicy = CoreTextInputPaneDisplayPolicy.Manual; 
+0

感谢您的回复!但它需要实现一个新的文本框控件,并且此示例显示的控件功能比内置文本框少。我试图实现文本框的继承,并在构造函数中添加代码,但它不起作用。 –

相关问题