#249 – Creating a Table in a FlowDocument
March 18, 2011 2 Comments
You can include a table in a FlowDocument as content by using the Table block. You present your content by laying it out as rows and columns.
<FlowDocument FontFamily="Cambria" FontSize="14"> <Paragraph>Some Pixar films:</Paragraph> <Table> <Table.Columns> <TableColumn Width="50*"/> <TableColumn Width="15*"/> <TableColumn /> </Table.Columns> <TableRowGroup Background="LightGray" FontWeight="Bold"> <TableRow> <TableCell><Paragraph>Title</Paragraph></TableCell> <TableCell><Paragraph>Year</Paragraph></TableCell> <TableCell><Paragraph>Director</Paragraph></TableCell> </TableRow> </TableRowGroup> <TableRowGroup FontFamily="Verdana" FontSize="12"> <TableRow> <TableCell><Paragraph>Toy Story</Paragraph></TableCell> <TableCell><Paragraph>1995</Paragraph></TableCell> <TableCell><Paragraph>John Lasseter</Paragraph></TableCell> </TableRow> <TableRow> <TableCell><Paragraph>Monster's, Inc.</Paragraph></TableCell> <TableCell><Paragraph>2001</Paragraph></TableCell> <TableCell><Paragraph>Pete Docter</Paragraph></TableCell> </TableRow> <TableRow> <TableCell><Paragraph>The Incredibles</Paragraph></TableCell> <TableCell><Paragraph>2004</Paragraph></TableCell> <TableCell><Paragraph>Brad Bird</Paragraph></TableCell> </TableRow> </TableRowGroup> </Table> </FlowDocument>
Hi,
Great article!
I am looking for a way to databind the Table in the FlowDocument with either an ObservableCollection object or a DataTable obj. Any help is greatly appreciated.
Thanks
Santosh
Take a look at http://www.websupergoo.com/helppdf7net/source/4-examples/21-wpftables.htm