rpf*_*rpf 10 .net c# wpf richtextbox wpf-controls
如何在RTF中获取文本RichTextBox
?我试图这样,但财产不存在.
RichTextBox rtb = new RichTextBox();
string s = rtb.Rtf;
Run Code Online (Sandbox Code Playgroud)
Mit*_*eat 16
要获取用户在RichTextBox内创建的实际XAML:
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());
Run Code Online (Sandbox Code Playgroud)
编辑:我没有在我面前测试代码,但该TextRange
类型的实例有一个Save
(to stream)方法,它接受一个DataFormats
参数,可以是DataFormats.Rtf
归档时间: |
|
查看次数: |
11678 次 |
最近记录: |