在FlowDocument中删除两个表之间的空格

时间:2018-06-20 19:51:57

标签: wpf xaml flowdocument

在我的FlowDocument中,我需要删除两个表之间的间距。我想可以通过将Block.Margin设置为0来实现此目的,就像Paragraph一样。尽管确实有所作为,但不能解决问题。

What my FlowDocument looks like

这是我的FlowDocument;

<FlowDocument>
    <FlowDocument.Resources>
        <Style TargetType="Paragraph" x:Key="{x:Type Paragraph}">
            <Style.Resources>
                <ResourceDictionary/>
            </Style.Resources>
            <Setter Property="Block.Margin">
                <Setter.Value>
                    <Thickness>0,0,0,0</Thickness>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="Table" x:Key="{x:Type Table}">
            <Style.Resources>
                <ResourceDictionary/>
            </Style.Resources>
            <Setter Property="Block.Margin">
                <Setter.Value>
                    <Thickness>0,0,0,0</Thickness>
                </Setter.Value>
            </Setter>
        </Style>
    </FlowDocument.Resources>
    <Table CellSpacing="0">
        <Table.Columns>
            <TableColumn/>
        </Table.Columns>
        <TableRowGroup>
            <TableRow>
                <TableCell>
                    <Table CellSpacing="0">
                        <Table.Columns>
                            <TableColumn/>
                            <TableColumn/>
                        </Table.Columns>
                        <TableRowGroup>
                            <TableRow FontSize="10" FontWeight="Normal" Foreground="#FF000000">
                                <TableCell>
                                    <Paragraph>Table 1</Paragraph>
                                </TableCell>
                                <TableCell>
                                    <Paragraph>Column 2</Paragraph>
                                </TableCell>
                            </TableRow>
                        </TableRowGroup>
                    </Table>
                    <Paragraph/>
                </TableCell>
            </TableRow>
        </TableRowGroup>
    </Table>
    <Table CellSpacing="0">
        <Table.Columns>
            <TableColumn/>
        </Table.Columns>
        <TableRowGroup>
            <TableRow>
                <TableCell>
                    <Table CellSpacing="0">
                        <Table.Columns>
                            <TableColumn/>
                            <TableColumn/>
                        </Table.Columns>
                        <TableRowGroup>
                            <TableRow FontSize="10" FontWeight="Normal" Foreground="#FF000000">
                                <TableCell>
                                    <Paragraph>Table 2</Paragraph>
                                </TableCell>
                                <TableCell>
                                    <Paragraph>Column 2</Paragraph>
                                </TableCell>
                            </TableRow>
                        </TableRowGroup>
                    </Table>
                    <Paragraph/>
                </TableCell>
            </TableRow>
        </TableRowGroup>
    </Table>
</FlowDocument>

1 个答案:

答案 0 :(得分:1)

只需删除表格下的空Paragraph标签,就可以了:

<FlowDocument>
<FlowDocument.Resources>
    <Style TargetType="Paragraph" x:Key="{x:Type Paragraph}">
        <Style.Resources>
            <ResourceDictionary/>
        </Style.Resources>
        <Setter Property="Block.Margin">
            <Setter.Value>
                <Thickness>0,0,0,0</Thickness>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="Table" x:Key="{x:Type Table}">
        <Style.Resources>
            <ResourceDictionary/>
        </Style.Resources>
        <Setter Property="Block.Margin">
            <Setter.Value>
                <Thickness>0,0,0,0</Thickness>
            </Setter.Value>
        </Setter>
    </Style>
</FlowDocument.Resources>
<Table CellSpacing="0">
    <Table.Columns>
        <TableColumn/>
    </Table.Columns>
    <TableRowGroup>
        <TableRow>
            <TableCell>
                <Table CellSpacing="0">
                    <Table.Columns>
                        <TableColumn/>
                        <TableColumn/>
                    </Table.Columns>
                    <TableRowGroup>
                        <TableRow FontSize="10" FontWeight="Normal" Foreground="#FF000000">
                            <TableCell>
                                <Paragraph>Table 1</Paragraph>
                            </TableCell>
                            <TableCell>
                                <Paragraph>Column 2</Paragraph>
                            </TableCell>
                        </TableRow>
                    </TableRowGroup>
                </Table>
            </TableCell>
        </TableRow>
    </TableRowGroup>
</Table>
<Table CellSpacing="0">
    <Table.Columns>
        <TableColumn/>
    </Table.Columns>
    <TableRowGroup>
        <TableRow>
            <TableCell>
                <Table CellSpacing="0">
                    <Table.Columns>
                        <TableColumn/>
                        <TableColumn/>
                    </Table.Columns>
                    <TableRowGroup>
                        <TableRow FontSize="10" FontWeight="Normal" Foreground="#FF000000">
                            <TableCell>
                                <Paragraph>Table 2</Paragraph>
                            </TableCell>
                            <TableCell>
                                <Paragraph>Column 2</Paragraph>
                            </TableCell>
                        </TableRow>
                    </TableRowGroup>
                </Table>
            </TableCell>
        </TableRow>
    </TableRowGroup>
</Table>
</FlowDocument>