简体   繁体   English

如何在WPF C#中将字符串资源中的文本添加为​​段落文本?

[英]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>

Binding in xaml: 在xaml中绑定:

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

in code behind : 在后面的代码中:
add x:name="paragraph" in xaml. 在xaml中添加x:name="paragraph" add like this in code behind: 在下面的代码中添加如下代码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM