table 单元格中的垂直对齐问题,flowdocument C#

vertical alignment issue in table cell, flowdocument C#

我正在尝试使用流文档

打印table

我创建了一个table如下图,但是单元格没有垂直对齐

我想在 table 单元格中居中垂直对齐。

我应该尝试什么?

<FlowDocument>
        <Table>
            <TableRowGroup>
                <TableRow>
                    <TableCell Background="Green" RowSpan="2">
                        <Paragraph>Cell 1</Paragraph>
                    </TableCell>
                    <TableCell>
                        <Paragraph Background="Yellow">Cell 2</Paragraph>
                    </TableCell>
                </TableRow>
                <TableRow>
                    <TableCell Background="Red">
                        <Paragraph>Cell 1</Paragraph>
                    </TableCell>

                </TableRow>
            </TableRowGroup>
        </Table>
</FlowDocument>

enter image description here

如果单元格始终具有相同的高度,您可以将段落顶部的边距偏移 10 并使文本居中:

<FlowDocument>
    <Table>
        <TableRowGroup>
            <TableRow>
                <TableCell Background="Green" RowSpan="2" TextAlignment="Center">

                    <Paragraph Margin="0,10,0,0">Cell 1</Paragraph>
                </TableCell>
                
                <TableCell>
                    <Paragraph Background="Yellow">Cell 2</Paragraph>
                </TableCell>
            </TableRow>
            <TableRow>
                <TableCell Background="Red">
                    <Paragraph>Cell 1</Paragraph>
                </TableCell>

            </TableRow>
        </TableRowGroup>
    </Table>
</FlowDocument>