Search code examples
c#wpfflowdocumentparagraph

How to initialize Paragraph Inlines


How can I initialize paragraph Inline with new InlineCollection? I defined InlineCollection and added Run elements with string to it. I tried to initialize this way

ParagraphComponent.Inlines = _inlineCollection;

However, I get error message that ParagraphComponent.Inline is readonly.


Solution

  • From the Remarks section of the Inlines property page on MSDN:

    Use the InlineCollection returned by this property to enumerate or manipulate the contents of a Paragraph element.

    So you could do this:

    ParagraphComponent.Inlines.Clear();
    ParagraphComponent.Inlines.AddRange(_inlineCollection);