gpt4 book ai didi

c# - 如何通过编程调整流文档中的段落间距

转载 作者:太空狗 更新时间:2023-10-29 21:51:06 24 4
gpt4 key购买 nike

我是C# Wpf的初学者,我想通过编程制作一个段落很少的流文档。问题是页面之间有很大的空间,我想将它的大小调整到最小。

我通过使用 Xml 语句找到了解决方案,但我想通过编程来实现:

<FlowDocument>
<FlowDocument.Resources>
<!-- This style is used to set the margins for all paragraphs in the FlowDocument to 0. -->
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
</FlowDocument.Resources>

<Paragraph>
Spacing between paragraphs is caused by margins set on the paragraphs. Two adjacent margins
will "collapse" to the larger of the two margin widths, rather than doubling up.
</Paragraph>

<Paragraph>
To eliminate extra spacing between two paragraphs, just set the paragraph margins to 0.
</Paragraph>
</FlowDocument>

我该怎么做?

谢谢你的帮助。

最佳答案

试试这个:

Style style = new Style(typeof(Paragraph));
style.Setters.Add(new Setter(Block.MarginProperty, new Thickness(0)));
myFlowDocument.Resources.Add(typeof(Paragraph), style);

关于c# - 如何通过编程调整流文档中的段落间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13540656/

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