/// <summary> /// Method that is called when the DocumentRtf property is changed /// </summary> /// <param name="d">RichTextBox being acted upon</param> /// <param name="e">Data concerning the change of the property</param> private static void RtfMetadataBinding(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (m_RecursProtectDocRtf.Contains(Thread.CurrentThread)) { return; } var trueBox = (RichTextBox)d; trueBox.TextChanged -= trueBox_TextChanged; var textRange = new TextRange(trueBox.Document.ContentStart, trueBox.Document.ContentEnd); var rtfStream = new MemoryStream(Encoding.UTF8.GetBytes(RtfHelper.FormatPlainToRtf((string)e.NewValue))); textRange.Load(rtfStream, DataFormats.Rtf); trueBox.TextChanged += trueBox_TextChanged; }