Single line borders in FlowDocument Tables

Holstebroe picture Holstebroe · Sep 23, 2010 · Viewed 9.5k times · Source

I have a FlowDocument table where I want to spice up the layout a bit. I'm thinking something like a thin line separating the sub amounts on an invoice from the total or something like the line under the header row typically featured in the standard Word 2007+ table styles. I was hoping that I could just add an empty TableRow and set the height to a few pixel units, but I find no property to force the height of a row to my desire.

Is there a way (or hack) to make a thin border line under or over an entire row in a System.Windows.Documents.Table?

Answer

Oliver Slay picture Oliver Slay · Jul 20, 2011

When I print this out it just looks like a feint line.

<TableRow FontSize="0.008">
    <TableCell Padding="0" BorderBrush="Gray" BorderThickness="0.5" ColumnSpan="5" />
</TableRow>

Make sure the Table has CellSpacing="0"

I define TableColumns for vertical lines between columns:

<Table.Columns>
    <TableColumn Width="140" Name="colItems" />
    <TableColumn Width="0" Name="colSpace1" />
    <TableColumn Name="colDescription" />
    <TableColumn Width="0" Name="colSpace2" />
    <TableColumn Width="150" Name="colAmount"/>
</Table.Columns>

Then in a TableRowGroup for the Header row:

<TableRow FontSize="14">
    <TableCell TextAlignment="Center" Padding="0,4,0,2">
        <Paragraph>ITEMS</Paragraph>
    </TableCell>
    <TableCell BorderBrush="Gray" BorderThickness="0.5" />
    <TableCell TextAlignment="Center" Padding="0,4,0,2">
        <Paragraph>DESCRIPTION</Paragraph>
    </TableCell>
    <TableCell BorderBrush="Gray" BorderThickness="0.5" />
    <TableCell TextAlignment="Center" Padding="0,4,0,2">
        <Paragraph>AMOUNT</Paragraph>
    </TableCell>
</TableRow>

Oliver