8

私は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>

どうすればいいですか?

助けてくれてありがとう。

4

2 に答える 2

4

これを試して:

Style style = new Style(typeof(Paragraph));
style.Setters.Add(new Setter(Block.MarginProperty, new Thickness(0)));
myFlowDocument.Resources.Add(typeof(Paragraph), style);
于 2012-11-24T11:22:23.070 に答える
2

「プログラミング」は必要ありません。PagePaddingプロパティは私のために働いFlowDocumentた:

<FlowDocument PagePadding="0">

PagePadding の MSDN 定義:

ページの境界とページのコンテンツの間のパディング スペースの厚さを示す値を取得または設定します。

于 2015-07-25T11:17:09.607 に答える