2017-07-16 24 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

感謝您的回覆!但它需要實現一個新的文本框控件,並且此示例顯示的控件功能比內置文本框少。我試圖實現文本框的繼承,並在構造函數中添加代碼,但它不起作用。 –

相關問題