Add table to FlowDocument in code

I tried this .....

_doc = new FlowDocument();

Table t = new Table();
for (int i = 0; i < 7; i++)
{
    t.Columns.Add(new TableColumn());
}

TableRow row = new TableRow();
row.Background = Brushes.Silver;
row.FontSize = 40;
row.FontWeight = FontWeights.Bold;

row.Cells.Add(new TableCell(new Paragraph(new Run("I span 7 columns"))));
row.Cells[0].ColumnSpan = 6;

_doc2.Blocks.Add(t);

      

When I go to view this document, the table never shows ..... although the frame image and document title that I add to this document is displayed fine before adding this table.

+2


a source to share


1 answer


You are adding columns to the table, but where is the code that adds the row? It's just not connected.

Add something like:



...
var rg = new TableRowGroup();
rg.Rows.Add(row);
t.RowGroups.Add(rg);
_doc2.Blocks.Add(t);

      

+4


a source







All Articles