title: Set RTF text into WPF RichTextBox control
body: <p>I have this RTF text:</p>
  <pre><code>{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}
  {\colortbl ;\red0\green0\blue0;\red255\green0\blue0;}
  \viewkind4\uc1\pard\qc\cf1\fs16 test \b bold \cf2\b0\i italic\cf0\i0\fs17 
  \par }
  </code></pre>
  <p>How to set this text into <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.aspx" rel="nofollow noreferrer">WPF RichTextBox</a>?</p>
  <hr>
  <p>Solution:</p>
  <pre><code>public void SetRTFText(string text)
  {
      MemoryStream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(text));
      this.mainRTB.Selection.Load(stream, DataFormats.Rtf);
  }
  </code></pre>