Wal*_*d A 6 c# wpf flowdocument
我是C#Wpf的初学者,我想通过编程制作一个几乎没有paragrah的流程文档.问题是pagraph之间有一个很大的空间,我想把它调整到最小.
我通过使用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>
Run Code Online (Sandbox Code Playgroud)
我该怎么做 ?.
thanx对你有所帮助.
尝试这个:
Style style = new Style(typeof(Paragraph));
style.Setters.Add(new Setter(Block.MarginProperty, new Thickness(0)));
myFlowDocument.Resources.Add(typeof(Paragraph), style);
Run Code Online (Sandbox Code Playgroud)