Search code examples
c#wpfflowdocument

how to add text from a string resource as a paragraph text in wpf c#?


I have a Flow Document and in its paragraphs I want to add text from a string resource, how do you do that?

<FlowDocument>
      <Paragraph>
         //string from resource//
      </Paragraph>
</FlowDocument>

Solution

  • Binding in xaml:

    <FlowDocument>
          <Paragraph>
            <Run Text={StsticResource yourString} />
         </Paragraph>
    </FlowDocument>
    

    in code behind :
    add x:name="paragraph" in xaml. add like this in code behind:

    paragraph.Inlines.Add(new Run(This.Resources["yourString"]));