Udostępnij za pośrednictwem


RichEditBox.TextChanging Event

Definition

Occurs synchronously when the text in the edit box starts to change, but before it is rendered.

// 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"/>

Event Type

Remarks

For event data, see RichEditBoxTextChangingEventArgs.

The TextChanging event occurs synchronously before the new text is rendered. In contrast, the TextChanged event is asynchronous and occurs after the new text is rendered.

When the TextChanging event occurs, the Document property already reflects the new value (but it's not rendered in the UI). You typically handle this event to update the text value and selection before the text is rendered. This prevents the text flickering that can happen when text is rendered, updated, and re-rendered rapidly.

Note

This is a synchronous event that can occur at times when changes to the XAML visual tree are not allowed, such as during layout. Therefore, you should limit code within the TextChanging event handler primarily to inspecting and updating the Document property. Attempting to perform other actions, such as showing a popup or adding/removing elements from the visual tree, might cause potentially fatal errors that can lead to a crash. We recommend that you perform these other changes either in a TextChanged event handler, or run them as a separate asynchronous operation.

Applies to

See also