UIElement.TextInput 事件

定义

在此元素以设备无关模式获取文本时发生。Occurs when this element gets text in a device-independent manner.

public:
 virtual event System::Windows::Input::TextCompositionEventHandler ^ TextInput;
public event System.Windows.Input.TextCompositionEventHandler TextInput;
member this.TextInput : System.Windows.Input.TextCompositionEventHandler 
Public Custom Event TextInput As TextCompositionEventHandler 

实现

注解

重要

此事件可能已标记为由复合控件的内部实现进行处理。This event might already be marked as handled by the internal implementations of composited controls. 请参阅下面的注释。See Remark below.

TextInput 事件可能已标记为由复合控件的内部实现进行处理。The TextInput event may already be marked as handled by the internal implementations of composited controls. 例如,TextBox 是一个复合控件,其中 TextInput 事件已标记为已处理;的组合。For example, a TextBox is a composited control where the TextInput event is already marked as handled; within its compositing. 控件这样做的原因是,控件需要解释某些类型的输入(如箭头键),以便对该控件具有特殊意义。Controls do this because the control needs to interpret some types of input, such as arrow keys, as having special meaning to that control. 如果使用 PreviewTextInput 作为文本输入的处理程序的事件,可能会获得更好的结果。If you use PreviewTextInput as the event where you attach handlers for text input, you may receive better results. 此方法可避免控件组合已将此事件标记为已处理并防止处理程序通过事件路由接收事件的大多数情况。This technique circumvents most cases where control composition has already marked this event as handled and prevents your handler from receiving the event along the event route.

TextInput 事件允许组件或应用程序以与设备无关的方式侦听文本输入。The TextInput event allows a component or application to listen for text input in a device-independent manner. 键盘是 TextInput的主要方式,但语音、手写和其他输入设备也会引发 TextInputThe keyboard is the primary means of TextInput, but speech, handwriting, and other input devices can also raise TextInput.

由于键组合(在默认键盘或通过输入法编辑器)中,多个键事件可能只引发一个文本输入事件。Because of key combinations - either in default keyboards or through input method editors - multiple key events might raise just one text input event.

此事件创建此类的 TextCompositionManager.TextInput 附加事件的别名,以便在将 UIElement 作为基元素继承时,TextInput 是类成员列表的一部分。This event creates an alias for the TextCompositionManager.TextInput attached event for this class, so that TextInput is part of the class members list when UIElement is inherited as a base element. 附加到 TextInput 事件的事件处理程序附加到基础 TextCompositionManager.TextInput 附加事件,并接收相同的事件数据实例。Event handlers that are attached to the TextInput event are attached to the underlying TextCompositionManager.TextInput attached event and receive the same event data instance.

路由事件信息Routed Event Information

标识符字段Identifier field TextInputEvent
路由策略Routing strategy 冒泡Bubbling
委托Delegate TextCompositionEventHandler

适用于