wpf富文本框中的rtf格式问题 [英] problem with rtf formatting in wpf rich textbox

查看:206
本文介绍了wpf富文本框中的rtf格式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在访问rtf内容到wpf RihtextBox时遇到问题,内容格式已丢失.....

我已经用其他方式做到了,但我想使用rtf格式.....



任何帮助就足够了...
谢谢....

i have a problem while accessing rtf content to wpf RihtextBox the content formatting has lost.....

i have done it with other way but i want to do it with rtf format.....



any help will be sufficient...
Thanks....

推荐答案

尝试以下操作:-

TextRange tr =新的TextRange(myRichTextBox.Document.ContentStart,
myRichTextBox.Document.ContentEnd);
MemoryStream ms =新的MemoryStream();
tr.Save(ms,DataFormats.Xaml);
字符串xamlText = ASCIIEncoding.Default.GetString(ms.ToArray());
我前面没有代码要测试,但是TextRange类型的实例具有一个Save(到流)方法,该方法采用DataFormats参数,该参数可以是DataFormats.Rtf

这不是我的答案,但这是其他人的副本!
Try this:-

TextRange tr = new TextRange(myRichTextBox.Document.ContentStart,
myRichTextBox.Document.ContentEnd);
MemoryStream ms = new MemoryStream();
tr.Save(ms, DataFormats.Xaml);
string xamlText = ASCIIEncoding.Default.GetString(ms.ToArray());
I don''t have code in front of me to test, but an instance of the TextRange type has a Save (to stream) method that takes a DataFormats parameter, which can be DataFormats.Rtf

This is not my answer but it is a copy from someother!


这篇关于wpf富文本框中的rtf格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆