我写了一个小的WPF应用程序,我喜欢在RichTextBox中预先添加文本,这样最新的东西就在最上面。我写了这个,它的工作原理:如何将图像添加到RichTextBlock的Run中?
/// <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);
}
}
现在我想作出一个新的版本,该功能可以添加小图像以及。尽管我很茫然 - 是否可以添加图片?
啊哈 - 我无法绕过位图 - >图像 - > inlineuicontainer - >段的事情。谢谢!! – 2008-10-15 20:16:59