bulleted/number list format in *.rtf file in WPF RichTextBox is disordered

Scott Q-0525 121 Reputation points

See below format in *.rft file, after load the *.rft file into WPF RichTextBox, the formats are disordered.

  1. string 1 AAA
  2. string 2
  • AB
  • BB

After load into RichTextBox, or using TextRange.Save to a new *.rtf again.


The source codes:

 var file = @"D:\my.rtf";
 this.myTestRichTextBox.Document = new FlowDocument();
 using (var stream = File.OpenRead(file))
     var textRange = new TextRange(myTestRichTextBox.Document.ContentStart, myTestRichTextBox.Document.ContentEnd);
    textRange.Load(stream, DataFormats.Rtf);



Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,483 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,032 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Hui Liu-MSFT 21,611 Reputation points Microsoft Vendor

    Hi,@Scott Q-0525. You could try the following code:

            <Button Content="show" HorizontalAlignment="Left" Margin="355,60,0,0" VerticalAlignment="Top" Click="Button_Click_1"/>
            <RichTextBox Name="myTestRichTextBox"  AcceptsReturn="True"  Height="100">
                        <Run Text="RichTextBox"/>
      string filePath = "C:\\...\\example.rtf";
            private void Button_Click_1(object sender, RoutedEventArgs e)
                    TextRange range;
                    System.IO.FileStream fStream;
                        range = new TextRange(myTestRichTextBox.Document.ContentStart, myTestRichTextBox.Document.ContentEnd);
                        fStream = new System.IO.FileStream(filePath, System.IO.FileMode.OpenOrCreate);
                        range.Load(fStream, System.Windows.DataFormats.Rtf);

    The result:

    enter image description here

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.