【问题标题】:WPF - Underline some text in RichtextboxWPF - 在 Richtextbox 中为某些文本加下划线
【发布时间】:2014-10-14 21:43:18
【问题描述】:

我有一个 WPF RichTextBox (rtbControl),内容如下:

这不是下划线
这是下划线

我想在第二行下划线,我该怎么做?

【问题讨论】:

    标签: c# wpf richtextbox underline text-formatting


    【解决方案1】:

    由于RTB的内容是FlowDocument,那么你必须创建适当的文档结构:

        <RichTextBox>
            <FlowDocument>
                <Paragraph>
                    <Run Text="This is not an underline line"/>
                </Paragraph>
                <Paragraph>
                    <Underline>
                        <Run Text="This is an underline line"/>
                    </Underline>
                </Paragraph>
            </FlowDocument>
        </RichTextBox>
    

    【讨论】:

      【解决方案2】:
      <RichTextBox>
          <FlowDocument>
              <Paragraph>
                  This is not an underline line
              </Paragraph>     
      
              <Paragraph>
                  <Underline>This is an underline line</Underline>
              </Paragraph>     
      
          </FlowDocument>       
      
      </RichTextBox>
      

      【讨论】:

        猜你喜欢
        • 2015-03-04
        • 2014-03-22
        • 2011-08-01
        • 1970-01-01
        • 2011-02-02
        • 1970-01-01
        • 2012-09-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多