0

I have a string filled as :

string link (Sorry but I couldn't add XAML formatted text in this text editor.)

I wanna convert this string to Paragraph class in run-time. So I can add it simply in RichTextBlock.

How can I convert this string to paragraph format? How can I do it

1 Answers1

0

Add some root element to the XAML so you can parse is as XML

var doc = XDocument.Parse("<root>"+yourStringVariable+"</root>");

the go over the paragraphs and process them

var paragraphs = new List<Paragraph>();
foreach (var p in doc.Descendants("Paragraph"))
{
    var paragraph = new Paragraph();
    paragraph.Inlines.Add(new Run {Text = p.Value});
}
Igor Kulman
  • 16,211
  • 10
  • 57
  • 118