Donate

Remove Formatting Of Last Selected Text In A WPF RichTextBox Control

Here's how to remove the formatting of last selected text in a WPF RichTextBox control from it's SelectionChanged event.
C# Code
1
2
3
4
5
6
private void rtbEditor_SelectionChanged(object sender, RoutedEventArgs e)
{
    //Clear previous selections.
    TextRange textRange = new TextRange(rtbEditor.Document.ContentStart, rtbEditor.Document.ContentEnd);
    textRange.ClearAllProperties();
}

Output
Remove Formatting Of Last Selected Text In A WPF RichTextBox Control

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

Pass GUID As Parameter To Action Using ASP.NET MVC ContribGrid