title: How to save content of RichTextBox in BlockUIContainer, to RTF file?
body: <p>I made two richtexbox, one small richtexbox nested in a big richtextbox by using BlockUIContainer, see XAML file below.       </p>
  
  <pre><code>    &lt;RichTextBox IsDocumentEnabled="True"  x:Name="first" HorizontalAlignment="Left" Height="174" Margin="120,136,0,0" VerticalAlignment="Top" Width="254" TextChanged="first_TextChanged" MouseDoubleClick="first_MouseDoubleClick"&gt;
          &lt;FlowDocument&gt;
              &lt;Paragraph&gt;
                  &lt;Run Text="RichTextBox"/&gt;
              &lt;/Paragraph&gt;
              &lt;BlockUIContainer&gt;
                  &lt;RichTextBox IsReadOnly="True" x:Name="second"  MouseDoubleClick="second_MouseDoubleClick" Width="239" TextChanged="second_TextChanged"&gt;
                      &lt;FlowDocument&gt;
                          &lt;Paragraph&gt;
                              &lt;Run Text="RichTextBox1"/&gt;
                              &lt;Run Language="en" Text="hh"/&gt;
                          &lt;/Paragraph&gt;
                      &lt;/FlowDocument&gt;
                  &lt;/RichTextBox&gt;
              &lt;/BlockUIContainer&gt;
          &lt;/FlowDocument&gt;
      &lt;/RichTextBox&gt;
  </code></pre>
  
  <p>I want contents of both richtexbox saved in a RTF file. Normally we can use  TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd), since now we have nested richtexbox, so i think TextRange is probablly not working. And maybe i will add some images in the richtextbox, so I want to try binary stream, see below. "first" is the name of big richtextbox. THE PATH is the path for RTF file.</p>
  
  <pre><code>FlowDocument document = first.Document;
  System.IO.Stream ms = new System.IO.MemoryStream();
  System.Windows.Markup.XamlWriter.Save(document, ms);
  byte[] data = new byte[ms.Length];
  ms.Position = 0;
  ms.Read(data, 0, data.Length);
  ms.Close();
  File.WriteAllBytes(THE PATH, data);
  </code></pre>
  
  <p>But in the saved RTF file, when i open it, it shows like this,</p>
  
  <pre><code>&lt;FlowDocument PagePadding="5,0,5,0" AllowDrop="True"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&gt; &lt;Paragraph&gt;RichTextBox&lt;/Paragraph&gt;&lt;Paragraph&gt;&lt;Run xml:lang="en"&gt;test test test!!!&lt;/Run&gt;&lt;/Paragraph&gt;&lt;BlockUIContainer&gt;&lt;RichTextBox IsReadOnly="True" Name="second" Width="239"&gt;&lt;FlowDocument PagePadding="5,0,5,0" AllowDrop="True"&gt;&lt;Paragraph&gt;RichTextBox1&lt;Run xml:space="preserve"&gt; &lt;/Run&gt;&lt;Run xml:lang="en"&gt;hhthis is a small richtextbox&lt;/Run&gt;&lt;/Paragraph&gt;&lt;Paragraph&gt;&lt;Run xml:lang="en" xml:space="preserve" /&gt;&lt;/Paragraph&gt;&lt;/FlowDocument&gt;&lt;/RichTextBox&gt;&lt;/BlockUIContainer&gt;&lt;/FlowDocument&gt;
  </code></pre>
  
  <p>I don´t want to see XAML plain text in the saved file, I want it to show like a normal word document, see below. and probably also see the border line of the small richtextbox (this border line doesnot show below)</p>
  
  <pre><code>RichTextBox
  test test test!!!
  RichTextBox1 hhthis is a small richtextbox
  </code></pre>
  
  <p>What should I do? or nested richtextbox by BlockUIContainer is not possible to show like this?</p>