首页 > 解决方案 > 从 WPF RichTextBox 获取图像和文本

问题描述

我有一个包含一些文本和图像的 WPF RichTextBox。我将如何提取所有这些并将其保存在任何地方?

目前它只能通过从 RichTextBox 获取文本来工作,但我也需要图像。这是我从 RichTextBox 中提取字符串的代码:

private string getStringFromRTB(RichTextBox rtb) {
      TextRange tr = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);
      return tr.Text;
}

标签: c#wpf

解决方案


欢迎来到 SO!

请改用TextRange.Save()andTextRange.Load()方法。


推荐阅读