c# - WPF writing html to a rich text box -


i working on wpf windows application using c# code. application inherited. have limited experience using wpf. have rich text box control used build email using html. there code read rich text box contents , store results html in database. code working. need write reverse writing html rich text box appears text.

below code have read rich text box.

 textrange xaml = new textrange(emailbodyrichtextbox.document.contentstart, emailbodyrichtextbox.document.contentend);             memorystream ms = new memorystream();             xaml.save(ms, dataformats.xaml);             string xamlstring = asciiencoding.default.getstring(ms.toarray());              string html = htmlconverter.htmlfromxamlconverter.convertxamltohtml("<flowdocument>" + xamlstring + "</flowdocument>");              html = httputility.htmlencode(html); 

to save richtextbox's content regular string can save in database:

string formattedemail = xamlwriter.save(emailbodyrichtextbox.document); 

to reload richtextbox string:

emailbodyrichtextbox.document = xamlreader.parse(formattedemail); 

if want store emails in database , reload them richtextboxes, there no point in converting html, can introduce conversion format mismatches.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -