从剪贴板移动或粘贴后,将图像的源字符串保存在 RichTextBox 中
我正在研究 Richtextbox,它可以处理图像。我将 richtextbox 的 xaml 内容作为字符串保存到数据库中。图像保存在文件夹树中。我有一个问题:
当我将图像插入到 richtextbox(在 InlineUIContainer 中)时,一切正常,保存和加载没有问题。但是当我再次拖动图像或剪切并粘贴图像时,图像的源路径发生了变化:
<Image>
<Image.Source>
<BitmapImage BaseUri="pack://payload:,,wpf1,/Xaml/Document.xaml"
UriSource="./Image1.jpeg" CacheOption="OnLoad" />
</Image.Source>
</Image>
原始源是:
<Image Source="pack://siteoforigin:,,,/path_to_image/some_image.jpg" />
因此,当我再次保存xaml(仍然一切正常)时,我无法再次加载图像,因为在xaml中有是通往它们的错误路径(不好:-))。
我搜索过,但没有找到任何解决方案。你能帮我一下吗?
I'm working on richtextbox, which can handle images. I'm saving xaml content of richtextbox to database as string. Images are saved in the folder tree. And I have one problem:
When I insert image to richtextbox (in InlineUIContainer) all is working, saving and loading makes no problem. But when I drag image or cut and paste image again, source path of image is changed:
<Image>
<Image.Source>
<BitmapImage BaseUri="pack://payload:,,wpf1,/Xaml/Document.xaml"
UriSource="./Image1.jpeg" CacheOption="OnLoad" />
</Image.Source>
</Image>
original source was:
<Image Source="pack://siteoforigin:,,,/path_to_image/some_image.jpg" />
And therefore, when I save xaml again (still everything ok), I can't load images again, because in the xaml there are wrong paths to them (not ok :-)).
I searched for it, but I haven't found any solution. Could You help me please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了另一种方法,我将其保存到 XAML 包中,将图像复制到其中,一切都很完美。
I found another way, I am saving it to the XAML package, Images are copied into it and everything works perfect.