0

System.Windows.Documents.TableColumnCollection.Columns definition states:

Gets a System.Windows.Documents.TableColumnCollection object that contains the columns hosted by the table. Note that this number might not be the actual number of columns rendered in the table. It is the System.Windows.Documents.TableCell objects in a table that determine how many columns are actually rendered.This property has no default value.

Please help me visualizing as to why I'd need to define table columns at all?

Vivek Shukla
  • 767
  • 6
  • 21

1 Answers1

1

A Table consists of columns and rows. A TableColumn defines a column within a Table and each row in the table is comprised of one or more cells that are represented by TableCell elements. The TableColumn elements typically defines the width of columns in which the cells are rendered.

Hopefully the following sample markup illustrates what I mean:

<FlowDocument>
    <Table>
        <Table.Columns>
            <TableColumn Width="2*" />
            <TableColumn Width="1*" />
            <TableColumn Width="1*" />
        </Table.Columns>
        <TableRowGroup>
            <TableRow>
                <TableCell>
                    <Paragraph>1</Paragraph>
                </TableCell>
                <TableCell>
                    <Paragraph>2</Paragraph>
                </TableCell>
                <TableCell>
                    <Paragraph>3</Paragraph>
                </TableCell>
            </TableRow>
        </TableRowGroup>
    </Table>
</FlowDocument>

The first column takes up half of the total width and the rest of the space is divided between column 2 and 3. If you don't define any columns, the space is divided equally between the cells.

mm8
  • 163,881
  • 10
  • 57
  • 88