15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Text elements ❘ 1083<br />

new SolidColorBrush(Colors.LightGray)};<br />

row2.Cells.Add(new TableCell(new Paragraph(new Run("2."))));<br />

row2.Cells.Add(new TableCell(new Paragraph(new Run("Sebastian Vettel"))));<br />

row2.Cells.Add(new TableCell(new Paragraph(new Run("84"))));<br />

var row3 = new TableRow();<br />

row3.Cells.Add(new TableCell(new Paragraph(new Run("3."))));<br />

row3.Cells.Add(new TableCell(new Paragraph(<br />

new Run("Rubens Barrichello"))));<br />

row3.Cells.Add(new TableCell(new Paragraph(new Run("77"))));<br />

var rowGroup = new TableRowGroup();<br />

rowGroup.Rows.Add(titleRow);<br />

rowGroup.Rows.Add(headerRow);<br />

rowGroup.Rows.Add(row1);<br />

rowGroup.Rows.Add(row2);<br />

rowGroup.Rows.Add(row3);<br />

t1.RowGroups.Add(rowGroup);<br />

doc.Blocks.Add(t1);<br />

reader.Document = doc;<br />

Running the application, you can see the nicely<br />

formatted table as shown in Figure 37-8.<br />

anchor to blocks<br />

Now that you’ve learned about the Inline <strong>and</strong><br />

Block elements, you can combine the two by using the figure 37-8<br />

Inline elements of type AnchoredBlock. AnchoredBlock is<br />

an abstract base class with two concrete implementations, Figure <strong>and</strong> Floater.<br />

code snippet TableDemo/MainWindow.xaml<br />

The Floater displays its content parallel to the main content with the properties HorizontalAlignment<br />

<strong>and</strong> Width.<br />

Starting from the earlier example, a new paragraph is added that contains a Floater. This Floater<br />

is aligned to the left <strong>and</strong> has a width of 160. As you can see in Figure 37-9, the next paragraph flows<br />

around it.<br />

<br />

<br />

Mary had a little lamb<br />

<br />

<br />

<br />

<br />

<br />

Sarah Josepha Hale<br />

<br />

<br />

<br />

<br />

<br />

Mary had a little lamb<br />

<br />

<br />

<br />

<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!