I have a RichEditBox that I want to convert to a RichTextBlock. To do that, I need to convert the RTF string to an XAML string. Is it possible to do that? Are there any NuGet packages for that?
Asked
Active
Viewed 67 times
1
-
Does this answer your question? [Convert RTF string to XAML string](https://stackoverflow.com/questions/26123907/convert-rtf-string-to-xaml-string) – marsh-wiggle Jun 10 '23 at 13:36
-
@marsh-wiggle No, because I'm on UWP – Ivirius Jun 11 '23 at 21:04
1 Answers
0
One possible way seems to be converting the RTF to HTML first and then from HTML to XAML
The RtfPipe library on GitHub has a 'ToHtml' method
using RtfPipe;
string htmlString = Rtf.ToHtml(rtfString);
Then you may use a HtmlToXamlConverter to get your XAML string
string xamlFlowDocument = HtmlToXamlConverter.ConvertHtmlToXaml(htmlString, true);

marsh-wiggle
- 2,508
- 3
- 35
- 52
-
I did this already, and it works, but some formatting is lost in the process – Ivirius Jun 13 '23 at 07:12