gpt4 book ai didi

c# - 在流文档或 WPF RichTextBox 中创建悬挂缩进

转载 作者:行者123 更新时间:2023-12-02 15:24:09 26 4
gpt4 key购买 nike

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

最佳答案

在 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

希望这有帮助,问候

关于c# - 在流文档或 WPF RichTextBox 中创建悬挂缩进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5340590/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com