Click here to Skip to main content
13,203,040 members (57,576 online)
Click here to Skip to main content
Add your own
alternative version


9 bookmarked
Posted 18 Mar 2010

StackPanel with FlowDocumentReader

, 18 Mar 2010
Rate this:
Please Sign up or sign in to vote.
We will learn how to employ a FlowDocumentReader inside a StackPanel


This is my third article, and is building on my previous two. The previous articles can be found here: 1 and 2. In this article, we will be learning what a FlowDocumentReader is and how we can use it with a StackPanel to add functionality to your WPF applications.

What is a StackPanel used for? A StackPanel allows the developer to stack elements in a specified direction. The direction is defined by the properties within the StackPanel. StackPanels are mostly used within list boxes or combo boxes, but in this example we will use the StackPanel with a FlowDocumentReader control.

What is a FlowDocumentReader, you ask? In a nutshell, a FlowDocumentReader is a control that provides functionality for viewing flow content. It gives the user the option to choose between many viewing modes. This control comes with a scroller and a search feature.

The Code!

First, we will create the DockPanel and add two TextBlocks. We will dock one TextBlock to the top of the DockPanel that will display the Project Euler (pronounced oiler) logo. The other TextBlock is docked on to the bottom, this will show a quote from Leonhard Euler.




Title="Sundeepan's Stack Panel Example">
<DockPanel LastChildFill="True">








<TextBlock DockPanel.Dock="Bottom"



For since the fabric of the universe is most perfect 
and the work of a most wise Creator,
nothing at all takes place in the universe in which some rule of 
maximum or minimum does not appear. 
- &#169; 1783 Euler  

Immediately following the last TextBlock, we add a StackPanel and dock it to the left of the DockPanel. Within the freshly added StackPanel, we place an Image of Leonhard Euler. See code below:








We now add a FlowDocumentReader as the last element in the DockPanel. Remember from the previous article Creating a WPF DockPanel using XAML if the LastChildFill="True", the last child added will fill the space that hasn't been occupied by the other children (this child is pretty needy!). In this instance, the FlowDocumentReader will be the last child and it will occupy the rest of the space. See the code below:

           <Bold>About Project Euler</Bold>
           <Bold>What is Project Euler?</Bold>
           Project Euler is a series of challenging mathematical/computer
           programming problems that will require more than just mathematical
           insights to solve. Although mathematics will help you arrive at
           elegant and efficient methods, the use of a computer and programming skills
           will be required to solve most problems.The motivation for starting
           Project Euler, and its continuation, is to provide a platform for the
           inquiring mind to delve into unfamiliar areas and learn new concepts
           in a fun and recreational context.
           <Bold>Who are the problems aimed at?</Bold>
           The intended audience include students for whom the basic curriculum
           is not feeding their hunger to learn, adults whose background was not
           primarily mathematics but had an interest in things mathematical,
           and professionals who want to keep their problem solving and mathematics
           on the edge.
           <Bold>Can anyone solve the problems?</Bold>
           The problems range in difficulty and for many the experience
           is inductive chain learning.
           That is, by solving one problem it will expose you to a new concept
           that allows you to undertake a previously inaccessible problem.
           So the determined participant will slowly but surely work his/her
           way through every problem.

Now your app should look like the screenshot above!


  • 18th March, 2010: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sundeepan Sen
Systems Engineer
United States United States
Sundeepan Sen has been involved with technology for as long as he can remember. He got his start with the internet as a sophomore in high school in 1995 at the age of 15 and hasn't stopped since. His first encounter with the Internet was on a 2400 baud modem on a VAX/VMS shell account. The first program he wrote is in assembly for a game called "Core War" it can be found here:

He likes all things technology and loves to learn anything that comes his way.

Sundeepan is also artistically gifted with music, graphics, drawing and poetry.

He is a Network Consultant providing services with the latest Microsoft technologies.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171020.1 | Last Updated 18 Mar 2010
Article Copyright 2010 by Sundeepan Sen
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid