SIGN UP MEMBER LOGIN:    
ARTICLE

Flow and List Document in WPF

Posted by Manish Tewatia Articles | WPF with C# October 13, 2010
In this article you will learn about how to create Flow Document and List Document in WPF.
Reader Level:

HTML clipboard

Flow Document: In flow document the content you will insert into it these contents adapts itself to fit the container, flow document content in WPF improves upon these current-day approaches by incorporating better pagination, multicolumn display, sophisticated hyphenation and text flow algorithms, and user-adjustable viewing preferences.

WPF flow document is build by using a combination of flow elements, these elements don't inherit from the familiar UIElement and FrameworkElement classes. Instead, they form an entirely separate branch of classes that derive from ContentElement and FrameworkContentElement.

Now that you've taken a look at the content element model, you're ready to assemble some content elements into a simple flow document. You create a flow document using the FlowDocument class.

Example of Flow Document

<Window x:Class="Documents.FlowContent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="FlowContent" Height="381" Width="525" >
            <FlowDocumentScrollViewer>
            <FlowDocument>
                <Paragraph>This is a Flow Document.</Paragraph>
            <Paragraph>Start working on Flow Document.</Paragraph>
        </FlowDocument>
        </FlowDocumentScrollViewer>
    </Window>

 Output Window

1.gif

List Document: The List element represents a bulleted or numeric list in the document to simplify more your document and make tham more easy to read and understandable to the user. You choose by setting the MarkerStyle property. You can also set the distance between each list item and its marker using theMarkerOffset property.

Example of List Document

<Window x:Class="Documents.FlowContent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="FlowContent" Height="381" Width="525" >
            <FlowDocumentScrollViewer>
            <FlowDocument>
            <Paragraph>Student's Name's:</Paragraph>
            <List>
                <ListItem>
                    <Paragraph>Manish</Paragraph>
                </ListItem>
                <ListItem>
                    <Paragraph>Rahul</Paragraph>
                </ListItem>
                <ListItem>
                    <Paragraph>Naveen</Paragraph>
                </ListItem>
                <ListItem>
                    <Paragraph>Sam</Paragraph>
                </ListItem>
                <ListItem>
                    <Paragraph>Govil</Paragraph>
                </ListItem>
                <ListItem>
                    <Paragraph>Jak</Paragraph>
                </ListItem>
            </List>
            <Paragraph Margin="0,30,0,0">Teacher's Name's</Paragraph>
            <List MarkerStyle="Decimal">
                <ListItem>
                    <Paragraph>Mr. Ashok</Paragraph>
                </ListItem>
                <ListItem>
                    <Paragraph>Mr.Bread</Paragraph>
                </ListItem>
                <ListItem>
                    <Paragraph>Mr.Amit</Paragraph>
                </ListItem>
            </List>
        </FlowDocument>
        </FlowDocumentScrollViewer>
    </Window>

Output Window

2.gif

Conclusion

I hope this article help you to understand how to create Flow and List Document in WPF.

Login to add your contents and source code to this article
share this article :
post comment
 

really helpfull :)

Posted by dipayan sukul Oct 27, 2011

How can i scroll to the bottom without using the scroll bar? I've tried FlowDocReader.Document.Blocks.LastBlock.BringIntoView(); as instructed in other sites but it doesn't work. Here is my code snippet: // Open document string filename = dlg.FileName; FileNameTextBox.Text = filename; Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(System.IO.File.ReadAllText(filename)); FlowDocument document = new FlowDocument(paragraph); FlowDocReader.Document = document; //next line - scroll to bottom - this doesn't work FlowDocReader.Document.Blocks.LastBlock.BringIntoView(); //next line - scroll to top - this works // FlowDocReader.Document.BringIntoView();

Posted by jeanie simmons Jun 14, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor