WPF supports two types of
major documents models which provide rich layout support for displaying large
amounts of text combined with features like scrolling, pagination and zoom: The
"Fixed Document" and the "Flow Document".
FIXED DOCUMENT:The format of fixed document is something like "what you see is what you get". They are XPS (Open XML Paper Specification) based fixed type set documents which are print ready.
<FlowDocumentPageViewer x:Name="flowdocviewer" x:Class="FlowDocumentWpf.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="350" Width="525">
<FlowDocument x:Name="flowdoc" Background="Yellow" Foreground="Black">
<Paragraph x:Name="para1" FontSize="12">
The following details have been obtained from Amazon to match your initial query.Some of the returned values may have been empty, so have been omitted from theresults shown here.Also where there have been more than one value returned via the Amazon Details, these to have been omitted for the sake of keeping things simple for this small demo application. Simple is good,when trying to show how something works
</Paragraph>
</FlowDocument>
</FlowDocumentPageViewer>
</FlowDocumentReader >
FIXED DOCUMENT:The format of fixed document is something like "what you see is what you get". They are XPS (Open XML Paper Specification) based fixed type set documents which are print ready.
Example Code for Fixed
Document:
<Window x:Class="DocumentTypesofWPF.MainWindow"
<DocumentViewer>
<FixedDocument>
<PageContent>
<FixedPage>
<TextBlock>This is an Example of Fixed Document</TextBlock>
</FixedPage>
</PageContent>
</FixedDocument>
</DocumentViewer>
<Window>
FLOW DOCUMENT: A flow
document is designed to "reflow content" depending on window size,
device resolution, and other environment variables. They are dynamic which
can layout the content dynamically based on details such as size of window and
resolution.
Example Code for Flow Document:
<Window x:Class="DocumentTypesofWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FixedDocument>
<PageContent>
<FixedPage>
<TextBlock>This is an Example of Fixed Document</TextBlock>
</FixedPage>
</PageContent>
</FixedDocument>
</DocumentViewer>
<Window>
Example Code for Flow Document:
<FlowDocumentReader x:Class="DocumentTypesofWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FlowDocument>
<Paragraph>
<Bold>I'm using Bold tags</Bold>
<LineBreak/>
This text is not Bold.
</Paragraph>
<List>
<ListItem>
<Paragraph>Sam</Paragraph>
</ListItem>
<ListItem>
<Paragraph>Sam2</Paragraph>
</ListItem>
<ListItem>
<Paragraph>Sam3</Paragraph>
</ListItem>
<ListItem>
<Paragraph>Sam4</Paragraph>
</ListItem>
<ListItem>
<Paragraph>Sam5</Paragraph>
</ListItem>
</List>
</FlowDocument>
</FlowDocumentReader>
Some of the things that can be done with Flow Documents:
- Paragraphing.
- Anchoring of images.
- Hyperlinks.
- Text blocks.
- Tables.
- Subscript/Superscript text.
- UIElements (such as Button etc).
- Text effects.
There are three levels of flow document reader controls built-in to the framework:
FlowDocumentPageViewer :Shows document as individual pages, and allows user to adjust zoom level.
Example Code :<FlowDocumentPageViewer x:Name="flowdocviewer" x:Class="FlowDocumentWpf.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="350" Width="525">
<FlowDocument x:Name="flowdoc" Background="Yellow" Foreground="Black">
<Paragraph x:Name="para1" FontSize="12">
The following details have been obtained from Amazon to match your initial query.Some of the returned values may have been empty, so have been omitted from theresults shown here.Also where there have been more than one value returned via the Amazon Details, these to have been omitted for the sake of keeping things simple for this small demo application. Simple is good,when trying to show how something works
</Paragraph>
</FlowDocument>
</FlowDocumentPageViewer>
FlowDocumentScrollViewer : Simply displays the entire document and provides a scroll bar. Like a web page
Example Code :
<FlowDocumentScrollViewer x:Name="flowdocviewer" x:Class="FlowDocumentWpf.MainWindow" x:Class="FlowDocumentWpf.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<FlowDocumentScrollViewer x:Name="flowdocviewer" x:Class="FlowDocumentWpf.MainWindow" x:Class="FlowDocumentWpf.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Height="350" Width="525">
<FlowDocument x:Name="flowdoc" Background="Yellow" Foreground="Black">
<Paragraph x:Name="para1" FontSize="12">
The following details have been obtained from Amazon to match your initial query.Some of the returned values may have been empty, so have been omitted from theresults shown here.Also where there have been more than one value returned via the Amazon Details, these to have been omitted for the sake of keeping things simple for this small demo application. Simple is good,when trying to show how something works
</Paragraph>
</FlowDocument>
</FlowDocumentScrollViewer>
FlowDocumentReader : Combines FlowDocumentScrollViewer and FlowDocumentPageViewer into a single control, and exposes text search facilities.
Example Code :
<FlowDocumentReader x:Name="flowdocviewer" x:Class="FlowDocumentWpf.MainWindow" x:Class="FlowDocumentWpf.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="350" Width="525">
<FlowDocument x:Name="flowdoc" Background="Yellow" Foreground="Black">
<Paragraph x:Name="para1" FontSize="12">
The following details have been obtained from Amazon to match your initial query.Some of the returned values may have been empty, so have been omitted from theresults shown here.Also where there have been more than one value returned via the Amazon Details, these to have been omitted for the sake of keeping things simple for this small demo application. Simple is good,when trying to show how something works
</Paragraph>
</FlowDocument>