
Populating a Flow Document
With the scope of a FlowDocument, you are able to add a number of block or in-line types. Recall the basics of
block and in-line types:
• Block types represent a rectangular region in a document that can only be separated across page
boundaries.
• Inline types add decorations to simple block types (line breaks, floaters, figures, hyperlinks, and
so on).
Assume you have added a <Paragraph> element within your <FlowDocument>. Be aware that a single
<FlowDocument> can have any number of <Paragraph> elements, as well as other block types.
<FlowDocument>
<Paragraph FontSize = "25" FontWeight = "Bold">Chapter 23</Paragraph>
<Paragraph FontSize = "35" FontWeight = "Bold">
ADO.NET Part II: The Disconnected Layer
</Paragraph>
<Paragraph>
This chapter picks up where the previous chapter left off. Here, you
will be introduced to the disconnected layer of ADO.NET. When you use
this facet of ADO.NET, you are able to model remote data in memory
within the client tier using numerous members of the System.Data
namespace (most notably, DataSet, DataTable, DataRow, DataColumn,
DataView, and DataRelation). By doing so, you are able to provide the
illusion that the calling tier is continuous connected to a remote
data source, while in reality they are simply operating on a local
copy of relational data.
</Paragraph>
</FlowDocument>
Beyond Paragraph, a <FlowDocument> may define the following sub-elements.All of these types are of
members of the ‘block’ category:
Here is an example of working with the Section and List types. For illustrative purposes, notice in the related
screen shot that the <FlowDocument> supports context menus as IsSelectionEnabled is true.
<FlowDocument>
<!-- A section of information -->
<Section Foreground = "Yellow" Background = "Black">
<Paragraph FontSize = "14">
C# and the .NET Platform, 4th ed.
</Paragraph>
<Paragraph FontSize = "14">
Preview of chapter 23...
</Paragraph>
</Section>
<Paragraph>Changes:</Paragraph>
<!-- Simple List -->
<List>
<ListItem>
<Paragraph>Custom data library</Paragraph>
</ListItem>
<ListItem>
<Paragraph>Transactions</Paragraph>
</ListItem>
</List>
...
</FlowDocument>
The BlockUIContainer is very useful when building FlowDocuments. This type allows you to embed
UIElements into your document. This can allow for user interactivity, editable sections, and option settings.
Consider the following new <FlowDocument>:
<FlowDocumentReader Grid.Row = "1" BorderBrush = "Black"
BorderThickness = "2">
<FlowDocument ColumnWidth = "400">
<Section Background = "GhostWhite">
<Paragraph>
A UIElement element may be embedded directly in flow content
by enclosing it in a BlockUIContainer element.
</Paragraph>
<BlockUIContainer>
<Button>Click me!</Button>
</BlockUIContainer>
<Paragraph>
Please pick your choices.
</Paragraph>
<BlockUIContainer>
<StackPanel>
<Label Foreground = "Blue">Choose a value:</Label>
<ComboBox>
<ComboBoxItem IsSelected = "True">a</ComboBoxItem>
<ComboBoxItem>b</ComboBoxItem>
<ComboBoxItem>c</ComboBoxItem>
</ComboBox>
<Label Foreground = "Red">Choose a value:</Label>
<StackPanel>
<RadioButton>x</RadioButton>
<RadioButton>y</RadioButton>
<RadioButton>z</RadioButton>
</StackPanel>
<Label>Enter a value:</Label>
<TextBox>
A text editor embedded in flow content.
</TextBox>
</StackPanel>
</BlockUIContainer>
</Section>
</FlowDocument>
</FlowDocumentReader>
Here is the rendered output:
Populating Flow Documents
Table of Contents
Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an
online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials
FlowDocument Sub-Element
|
Meaning in Life
|
Section
|
Allows you to establish common property settings for blocks (e.g., background color, font, and more).
|
List
|
Allows you to create a list within a document.
|
Table
|
Allows you to organize content into rows and columns similar to an HTML table.
|
BlockUIContainer
|
Used to embed content into a document. It is the perfect way to display graphics, animations, or video feeds.
You can also display a UIElement in a BlockUIContainer (Buttons, TreeViews, and so on).
|
|
Services