RichEditBox.TextChanging 事件

定义

当编辑框中的文本开始更改时,但在呈现之前同步发生。

// Register
event_token TextChanging(TypedEventHandler<RichEditBox, RichEditBoxTextChangingEventArgs const&> const& handler) const;

// Revoke with event_token
void TextChanging(event_token const* cookie) const;

// Revoke with event_revoker
RichEditBox::TextChanging_revoker TextChanging(auto_revoke_t, TypedEventHandler<RichEditBox, RichEditBoxTextChangingEventArgs const&> const& handler) const;
public event TypedEventHandler<RichEditBox,RichEditBoxTextChangingEventArgs> TextChanging;
function onTextChanging(eventArgs) { /* Your code */ }
richEditBox.addEventListener("textchanging", onTextChanging);
richEditBox.removeEventListener("textchanging", onTextChanging);
- or -
richEditBox.ontextchanging = onTextChanging;
Public Custom Event TextChanging As TypedEventHandler(Of RichEditBox, RichEditBoxTextChangingEventArgs) 
<RichEditBox TextChanging="eventhandler"/>

事件类型

注解

有关事件数据,请参阅 RichEditBoxTextChangingEventArgs

TextChanging 事件在呈现新文本之前同步发生。 相反, TextChanged 事件是异步的,在呈现新文本后发生。

发生 TextChanging 事件时, Document 属性已反映新值 (但它不会呈现在 UI) 中。 通常处理此事件以在呈现文本之前更新文本值和所选内容。 这可以防止快速呈现、更新和重新呈现文本时可能发生的文本闪烁。

注意

这是一个同步事件,在不允许更改 XAML 可视化树时(例如在布局期间)时可能发生。 因此,应将 TextChanging 事件处理程序中的代码主要限制为检查和更新 Document 属性。 尝试执行其他操作(例如显示弹出窗口或添加/删除可视化树中的元素)可能会导致可能导致崩溃的致命错误。 建议在 TextChanged 事件处理程序中执行这些其他更改,或者将它们作为单独的异步操作运行。

适用于

另请参阅