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 事件處理程式中執行這些其他變更,或將它們當做個別的異步操作來執行。

適用於

另請參閱