1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
| this.richTextBox.Document = new FlowDocument(); richTextBox.AppendText("test test test test test test test test."); richTextBox.SelectAll(); richTextBox.Selection.ApplyPropertyValue(Paragraph.MarginProperty, new Thickness(30, 0, 0, 0)); richTextBox.Selection.ApplyPropertyValue(Paragraph.TextIndentProperty, -10.0);
var dataString = string.Empty; var textRange = new TextRange(this.richTextBox.Document.ContentStart, this.richTextBox.Document.ContentEnd); using (MemoryStream memoryStream = new MemoryStream()) { textRange.Save(memoryStream, DataFormats.Rtf); memoryStream.Seek(0, SeekOrigin.Begin); using (StreamReader streamReader = new StreamReader(memoryStream)) dataString = streamReader.ReadToEnd(); }
textRange = new TextRange(this.richTextBox.Document.ContentStart, this.richTextBox.Document.ContentEnd); using (MemoryStream memoryStream = new MemoryStream(Encoding.ASCII.GetBytes(dataString))) { textRange.Load(memoryStream, DataFormats.Rtf); }
|