【问题标题】:vertical alignment issue in table cell, flowdocument C#表格单元格中的垂直对齐问题,flowdocument C#
【发布时间】:2021-08-05 23:21:21
【问题描述】:

我正在尝试使用流文档打印表格

我创建了一个如下图所示的表格,但是单元格没有垂直对齐。

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

我应该尝试什么?

<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

【问题讨论】:

    标签: c# wpf flowdocument tablecell


    【解决方案1】:

    如果单元格始终具有相同的高度,您可以将段落在顶部偏移 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-03
      • 1970-01-01
      • 2011-01-23
      相关资源
      最近更新 更多