この例では、フロー コンテンツ内の段落間の間隔を調整または削除する方法を示します。
フロー コンテンツでは、段落間に表示される余分なスペースは、これらの段落に設定された余白の結果です。したがって、段落間の間隔は、それらの段落の余白を調整することによって制御できます。 2 つの段落間の余分な間隔を完全になくすには、段落の余白を 0に設定します。 FlowDocument全体で段落間の間隔を均一にするには、スタイル設定を使用して、FlowDocument内のすべての段落に均一な余白値を設定します。
2 つの隣接する段落の余白は、倍になるのではなく、2 つの余白の大きい方に "折りたたまれる" という点にご注意ください。 したがって、隣接する 2 つの段落にそれぞれ 20 ピクセルと 40 ピクセルの余白がある場合、段落間の結果のスペースは 40 ピクセルになり、2 つの余白値のうち大きくなります。
例
次の例では、スタイルを使用して、
<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>
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET Desktop feedback