我試圖設計一個FlowDocument,使其表現方式與在MS Word中輸入文本時的行爲相同。目前,我在列表項目中留有段落邊距。我已經使它看起來只是我想要的方式:使用此XAMLWPF FlowDocument - 列表項中的樣式段落
:
<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: How to convert FlowDocument to rtf
我的問題是: 是否有任何其他方式用於常規的段落和段落是一個ListItem的孩子設置不同的利潤率?我需要使用一般樣式來解決這個問題,而不是直接在段落上設置Style或Margin屬性。