【发布时间】:2008-10-13 20:26:49
【问题描述】:
我编写了一个小型 WPF 应用程序,我喜欢在其中将文本添加到 RichTextBox 中,以便将最新的内容放在首位。我写了这个,它有效:
/// <summary>
/// Prepends the text to the rich textbox
/// </summary>
/// <param name="textoutput">The text representing the character information.</param>
private void PrependSimpleText(string textoutput)
{
Run run = new Run(textoutput);
Paragraph paragraph = new Paragraph(run);
if (this.RichTextBoxOutput.Document.Blocks.Count == 0)
{
this.RichTextBoxOutput.Document.Blocks.Add(paragraph);
}
else
{
this.RichTextBoxOutput.Document.Blocks.InsertBefore(this.RichTextBoxOutput.Document.Blocks.FirstBlock, paragraph);
}
}
现在我想制作一个新版本的功能,它也可以添加小图像。我很茫然 - 可以添加图像吗?
【问题讨论】: