When I press Enter, I send a message and the field is cleared.

private void Clear_Enter(object sender, KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter) { string str; Message_BOX.Document.GetText(Windows.UI.Text.TextGetOptions.None, out str); while (str[str.Length - 1] == '\n' || str[str.Length - 1] == '\r') str = str.Substring(0, str.Length - 1); Message_BOX.Document.SetText(Windows.UI.Text.TextSetOptions.None, str); } } 

But before cleaning, there is still a line break and the transfer animation is visible. How to remove the transfer?

    1 answer 1

    In my opinion, the easiest and surest way to achieve the desired effect is to create a successor to the RichEditBox and override the OnKeyDown method. Here is what it might look like:

     public class CustomRichTextBox : RichEditBox { protected override void OnKeyDown(KeyRoutedEventArgs e) { // invoked anytime a key is pressed down, independent of focus if(e.Key == VirtualKey.Enter) { Document.SetText(Windows.UI.Text.TextSetOptions.None, ""); return; } base.OnKeyDown(e); } } 

    We do not skip Enter to the RichEditBox handler, so there will be no handling of pressing this key, therefore you will not see any animation or anything else.