15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1080 ❘ ChaPTer 37 creAtinG dOcuments with wpf<br />

<br />

<br />

<br />

<br />

<br />

code snippet FlowDocumentsDemo/FlowDocument2.xaml<br />

block<br />

Block is an abstract base class for block-level elements. Blocks allow grouping elements contained to specific<br />

views. Common with all blocks are the properties PreviousBlock, NextBlock, <strong>and</strong> SiblingBlocks that<br />

allow you to navigate from block to block. Setting BreakPageBefore <strong>and</strong> BreakColumnBefore page <strong>and</strong><br />

column breaks are done before the block starts. A Block also defines a border with the BorderBrush<br />

<strong>and</strong> BorderThickness properties.<br />

Classes that derive from Block are Paragraph, Section, List, Table, <strong>and</strong> BlockUIContainer. BlockUI<br />

Container is similar to InlineUIContainer in that you can add elements that derive from UIElement.<br />

Paragraph <strong>and</strong> Section are simple blocks where Paragraph contains inline elements; Section is used to<br />

group other Block elements. With the Paragraph block you can determine whether a page or column break<br />

is allowed within the paragraph or between paragraphs. KeepTogether can be used to disallow breaking<br />

within the paragraph; KeepWithNext tries to keep one paragraph <strong>and</strong> the next together. If a paragraph is<br />

broken by a page or column break, MinWidowLines defines the minimum number of lines that are placed<br />

after the break <strong>and</strong> MinOrphanLines defines the minimum number of lines before the break.<br />

The Paragraph block also allows decorating the text within the paragraph with TextDecoration elements.<br />

Predefined text decorations are defined by TextDecorations: Baseline, Overline, Strikethrough, <strong>and</strong><br />

Underline.<br />

The following XAML code shows multiple Paragraph elements. One Paragraph element with a title<br />

follows another with the content belonging to this title. These two paragraphs are connected with the<br />

attribute KeepWithNext. It’s also assured that the paragraph with the content is not broken by setting<br />

KeepTogether to True. The result is shown in Figure 37-6.<br />

<br />

<br />

Lyrics<br />

<br />

<br />

<br />

Mary had a little lamb<br />

<br />

<br />

<br />

<br />

Mary had a little lamb,<br />

<br />

<br />

<br />

little lamb, little lamb,<br />

<br />

<br />

<br />

Mary had a little lamb,<br />

<br />

<br />

<br />

whose fleece was white as snow.<br />

<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!