c# - WPF RichTextBox RTF update text? -
i have wpf richtextboxwhich formatted rtf. have method dynamically adds hyperlinks.
however when richtextbox text edited adding said hyperlink, rtf output incorrect because hyperlink appended end of complete rtf document.
i have managed format richtextbox rtf text text solves text display in richtextbox hyperlink lost plain text.
is there way of taking rtf richtextbox text , 're-loading' new flow document correct rtf output?
i have method i'm passing in rtf string (richtextbox.text) gives me correct rtf rtf tags in richtextbox text...
public void rebuildrtfforrichtextbox(string richtextboxtext) { flowdocument doc = new flowdocument(new paragraph(new run(richtextboxtext))); richtextboxarticlebody.document = doc; }
as mentioned richtextbox has property named "document". getting property return flowdocument. if read this , can see flowdocuments made of blocks. can iterate on blocks of flow document using "blocks" property .
using
flowdoc.blocks.insertbefore(flowdoc.blocks.firstblock, p); you able insert 1 block before . visit here learn how add paragraphs or other types of blocks.
Comments
Post a Comment