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