I am trying to style a FlowDocument to make it behave the same way as when entering text in MS Word. Right now, I am stuck with paragraph margins within a listitem. I have made it look just about the way I want to:
using this 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>
My problem now is that I also need to be able to convert the FlowDocument to RTF and make it look good. When converting to RTF, it seems like the the style triggers are ignored.
I use this method to convert to RTF: How to convert FlowDocument to rtf
My question is: Is there any other way to set different margins for a regular paragraph and a paragraph that is child of a listitem? I need to solve this using general styles, and NOT by setting the Style or Margin attribute directly on the paragraphs.