【问题标题】:Creating a Hanging indent in either a flow document or WPF RichTextBox在流文档或 WPF RichTextBox 中创建悬挂缩进
【发布时间】:2011-03-18 04:49:08
【问题描述】:

有没有办法在流文档或 system.windows.control RichTextBox(wpf) 中创建悬挂缩进?如果它可以在流文档中工作,当我将它加载到 RichTextBox 中以显示它时,它会保持它的形式吗?

【问题讨论】:

    标签: c# wpf richtextbox flowdocument indentation


    【解决方案1】:

    在 FlowDocument 段落定义中,您可以将左边距设置为悬挂缩进值,然后将 TextIndent 设置为该值的负数。下面是一个例子:

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
    
        <FlowDocumentScrollViewer>
            <FlowDocument>
                <Section>
                    <Paragraph TextIndent="-30" Margin="30,20,0,0">
                        The first line of this paragraph is not indented, but the rest of the lines will be indented by 30 units. The first line of this paragraph is not indented, but the rest of the lines will be indented by 30 units.
                    </Paragraph>
                </Section>
            </FlowDocument>
        </FlowDocumentScrollViewer>
    
        <RichTextBox Grid.Row="1">
            <FlowDocument>
                <Section>
                    <Paragraph TextIndent="-60" Margin="60,20,0,0">
                        The first line of this paragraph is not indented, but the rest of the lines will be indented by 60 units. The first line of this paragraph is not indented, but the rest of the lines will be indented by 60 units.
                    </Paragraph>
                </Section>
            </FlowDocument>
        </RichTextBox>
    </Grid>
    

    这里有更多关于缩进的细节WPF Documents - Indenting Paragraphs

    希望这会有所帮助,问候

    【讨论】:

      猜你喜欢
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-10
      相关资源
      最近更新 更多