WPF RichTextBox

以块的派生类进行显示

使用继承自System.Windows.Documents.Block以获取块状显示方式

示例 整个行

t.Document.Blocks.Add(new BlockUIContainer(new TextBlock() { Text = "AADAA", Foreground = Brushes.Red }));

示例 长度为内容长度

t.Document.Blocks.Add(new Paragraph(new InlineUIContainer(new TextBlock() { Text = "Auto" })));
原文地址:https://www.cnblogs.com/QuXingBai-Blog/p/14092578.html