您好,用RichTextBoxToolbar这个控件时可以显示的,但是我这只想要插入图片这一个功能,就自定义一个浏览显示代码如下:
OpenFileDialog openfile = new OpenFileDialog();
openfile.Filter = "*.jpg,*.jpeg,*.bmp,*.gif,*.ico,*.png,*.tif,*.wmf|*.jpg;*.jpeg;*.bmp;*.gif;*.ico;*.png;*.tif;*.wmf";
openfile.Title = "打开图像文件";
openfile.Multiselect = true;
Uri uri = null;
if (openfile.ShowDialog() == true)
{
//获取图片路径
uri = new Uri(openfile.FileName, UriKind.Absolute);
//把图片插入到指定的位置
using (new DocumentHistoryGroup(rtb.DocumentHistory))
{
rtb.Selection.Delete();
var source = new BitmapImage(uri);
var newElement = new C1InlineUIContainer { Content = source, ContentTemplate = ImageAttach.ImageTemplate };
rtb.Selection.Start.InsertInline(newElement);
}
}
这样的话rhtb2.Html = rhtb1.Html图片就显示不出来了 |