WPF: Types of Documents

WPF supports 2 types of major documents models which provide rich layout support for displaying large amounts of text combined with features


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.

Example:

<
Window x:Class
="FixedDocument.MainWindow"
xmlns
=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow" Height="350" Width="525" ResizeMode
="NoResize">
<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 are dynamic which can layout the content dynamically based on details such as size of window and resolution.


Example:

<
FlowDocumentReader
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns
:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FlowDocument>
  <Paragraph>
    <Bold>Some bold text in the paragraph.</Bold>
    Some text that is not bold.
  </Paragraph>
    <List>
      <ListItem>
        <Paragraph>ListItem 1</Paragraph>
      </ListItem>
      <ListItem>
        <Paragraph>ListItem 2</Paragraph>
      </ListItem>
      <ListItem>
        <Paragraph>ListItem 3</Paragraph>
      </ListItem>
    </List>
</FlowDocument>
</
FlowDocumentReader>