我正在尝试设置 FlowDocument 的样式,以使其行为方式与在 MS Word 中输入文本时相同。现在,我被一个列表项中的段落边距困住了。我让它看起来就像我想要的那样:
使用此 XAML:
<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FlowDocument.Resources>
<Style TargetType="Paragraph">
<Setter Property="Margin" Value="0,0,0,20" />
<Style.Triggers>
<DataTrigger Binding="{Binding Margin, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListItem}, AncestorLevel=1}}" Value="0">
<Setter Property="Margin" Value="5" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type List}">
<Setter Property="Margin" Value="5" />
</Style>
</FlowDocument.Resources>
<List>
<ListItem>
<Paragraph>Bullet1</Paragraph>
</ListItem>
<ListItem>
<Paragraph>Bullet2</Paragraph>
<List>
<ListItem>
<Paragraph>Bullet2.1</Paragraph>
<List>
<ListItem>
<Paragraph>Punkt 2.1.1</Paragraph>
</ListItem>
</List>
</ListItem>
</List>
</ListItem>
</List>
<Paragraph>Regular paragraph 1</Paragraph>
<Paragraph>Regular paragraph 2</Paragraph>
</FlowDocument>
我现在的问题是我还需要能够将 FlowDocument 转换为 RTF 并使其看起来不错。转换为 RTF 时,样式触发器似乎被忽略了。
我使用此方法转换为 RTF: 如何将 FlowDocument 转换为 rtf
我的问题是:有没有其他方法可以为常规段落和列表项的子段落设置不同的边距?我需要使用一般样式来解决这个问题,而不是直接在段落上设置 Style 或 Margin 属性。