#246 – Use FlowDocument Control to Host Entire Documents
March 15, 2011 Leave a comment
The FlowDocument control provides richer functionality than Label and TextBlock for displaying text.
A FlowDocument contains a collection of blocks, each of which is a separate paragraph, list, section or table. Below is a simple example.
<FlowDocument FontFamily="Cambria" FontSize="16"> <Paragraph FontFamily="Arial" FontSize="14"> Excerpt from <Italic>White Fang</Italic>, by <Bold>Jack London</Bold> </Paragraph> <Paragraph> A second cry arose, piercing the silence with needle-like shrillness. Both men located the sound. It was to the rear, somewhere in the snow expanse they had just traversed. A third and answering cry arose, also to the rear and to the left of the second cry. </Paragraph> <Paragraph> “They’re after us, Bill,” said the man at the front. </Paragraph> <Paragraph> His voice sounded hoarse and unreal, and he had spoken with apparent effort. </Paragraph> </FlowDocument>
Note that the content in the document automatically flows to fit the available space.