wpf中RichTextBox文本内容的赋值与获取

赋值:

richtextbox.Document.Blocks.Clear();

string srt="12356457";

Run run=new Run(str);

Paragraph p=new Paragraph();

p.Inlines.add(run);

richtextbox.Document.Blocks.Add(p);

获取:

TextRange textRange = new TextRange(richtextbox.Document.ContentStart, richtextbox.Document.ContentEnd);

return textRange.Text;

posted @ 2020-04-14 11:26  岳凯歌  阅读(4051)  评论(0编辑  收藏  举报