The community is working on translating this tutorial into isiZulu, but it seems that no one has started the translation process for this article yet. If you can help us, then please click "More info".
The FlowDocumentReader control
The FlowDocumentReader is definitely the most advanced read-only wrapper that you can place around a FlowDocument. It offers buttons that allows the end user to toggle between the rendering modes offered by the FlowDocumentScrollViewer and the FlowDocumentPageViewer, as well as out-of-the-box document searching and of course controls for zooming in and out.
All of this functionality also makes the FlowDocumentReader the heaviest of the three read-only wrappers, but this should hardly be an issue with most regularly sized documents. Here's an example of how the FlowDocumentReader might look:
This screenshot is taken in the page-based view, which is the default. You can switch between the view modes using the buttons to the left of the zoom controls. In the left part of the toolbar, you have the controls for searching through the document, as I have done here on the screenshot.
Here's the code that will give you the above result:
<Window x:Class="WpfTutorialSamples.Rich_text_controls.FlowDocumentReaderSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="FlowDocumentReaderSample" Height="250" Width="550">
<Grid>
<FlowDocumentReader>
<FlowDocument>
<Paragraph>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce faucibus odio arcu, luctus vestibulum tortor congue in. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec lacinia neque. Donec malesuada, ligula non vestibulum cursus, urna purus pellentesque orci, aliquet accumsan dui velit ac justo. Phasellus sagittis ligula in leo dapibus, vel vestibulum felis mattis. Fusce vitae auctor nibh. Ut sit amet fringilla turpis. Aenean tincidunt feugiat sapien, quis scelerisque enim pretium commodo. Mauris fermentum posuere nulla, vitae fermentum quam malesuada in. Cras ultrices bibendum nulla eu mollis. Sed accumsan pretium magna, non sodales velit viverra id. Sed eu elit sit amet sem ullamcorper rhoncus.</Paragraph>
<Paragraph>Nulla vitae suscipit tellus. Nunc sit amet tortor fermentum, sollicitudin enim cursus, sagittis lacus. Pellentesque tincidunt massa nisl, nec tempor nulla consequat a. Proin pharetra neque vel dolor congue, at condimentum arcu varius. Sed vel luctus enim. Curabitur eleifend dui et arcu faucibus, sit amet vulputate libero suscipit. Vestibulum ultrices nisi id metus ultrices, eu ultricies ligula rutrum. Phasellus rhoncus aliquam pretium. Quisque in nunc erat. Etiam mollis turpis cursus, sagittis felis vel, dignissim risus. Ut at est nec tellus lobortis venenatis. Fusce elit mi, gravida sed tortor at, faucibus interdum felis. Phasellus porttitor dolor in nunc pellentesque, eu hendrerit nulla porta. Vestibulum cursus placerat elit. Nullam malesuada dictum venenatis. Interdum et malesuada fames ac ante ipsum primis in faucibus.</Paragraph>
</FlowDocument>
</FlowDocumentReader>
</Grid>
</Window>
This markup will result in a window as seen on the screenshot above. Here's a screenshot where we've gone into the two-page mode as well as reduced the zoom a bit:
The FlowDocumentReader has a range of properties that can help you in controlling how it works. Here's an incomplete list of some of the most important ones:
ViewingMode - controls the initial viewing mode. The default is Page, but you can change that into Scroll or TwoPage , if you want another default view. This can still be changed by the user, unless specifically disabled.
IsFindEnabled - gives you the ability to disable searching in the document. If disabled, the search button will be removed from the toolbar.
IsTwoPageViewEnabled , IsPageViewEnabled and IsScrollViewEnabled - allows you to turn off a specific viewing mode for the reader. When set to false, this mode is no longer available for the reader and the button is removed from the toolbar.
Zoom - allows you to set the default zoom level. The standard is 100%, but you can change this by using the Zoom property.
Summary
We've now been through all the choices for a read-only FlowDocument wrapper, and as you can probably see, which one to choose really depends on the task at hand.
If you just want simple FlowDocument rendering with a scrollbar you should go with the FlowDocumentScrollViewer - it's simple and is the least space and resource consuming of the three. If you want a paged view, go with the FlowDocumentPageViewer, unless you want your user to be able to switch between the modes and be able to quickly search, in which case you should use the FlowDocumentReader.