title: C#: Richtextbox for a Instant Messager (Chat)
body: <p>i want my own Instant Messager (Chat). And the normal textbox doesn't support formatted/colored text.
  I read some articles about the Richtextbox in WPF and the new concept with Blocks, Paragraphs and Runs is pretty interesting.
  Is it a good idea to serialize these objects and send them to the other chat-clients? (The text should be formatted, like the author's orginal text)
  If i want to add the blocks from the input-textbox to the output-textbox (only for testing), i get a exception that the blocks/paragraphs are used by an other richtextbox.
  Then i saved the reference from these objects, removed it from the first textbox and added them to the second textbox.</p>
  
  <pre><code> For example:
  
  
      FlowDocument oldTextDocument = richTextBoxMessageBox.Document;
  
              richTextBoxMessageBox.Document = new FlowDocument();
  
              while(oldTextDocument.Blocks.Count &gt; 0)
              {
                  richTextBoxChatHistory.Document.Blocks.Add(oldTextDocument.Blocks.FirstBlock);
              }
  </code></pre>
  
  <p>(I cant do it with for-each because this will cause a exception.)</p>