Export (0) Print
Expand All

Try it: Create a FlowDocumentReader control

This page applies to WPF projects only

In the Properties panel, some properties are more complex than a single value. For example, some properties represent a collection of values, or represent an object with properties of its own. You can use the collection editor and the subproperty editor to modify these values.

The following procedure uses the subproperty and collection editors to show you how to add content to a FlowDocumentReader control.

NoteNote

You do not have to use this procedure to modify text in a FlowDocumentScrollViewer control. Instead, you can use the procedures in Edit text, Format text, and the other topics that are listed in the "How to" section in Drawing text.

To add content to a FlowDocumentReader control

  1. The FlowDocumentReader control is available from the Assets panel. In the Tools panel, click Assets Cc294699.0d8b8d29-1af9-418f-8741-be3097d76eab(en-us,Expression.40).png.

  2. In the Controls category, click All to see all the available controls.

  3. Select the FlowDocumentReader control from the list of controls. A generic icon appears underneath the Assets button in the Tools panel, selected and ready to be added to the artboard.

  4. Draw a FlowDocumentReader on the artboard.

    A FlowDocumentReader control drawn on the artboard

    Cc294699.341a31f1-c5ea-4d83-b371-b2097f00cb27(en-us,Expression.40).png
  5. With the FlowDocumentReader object selected in the Objects and Timeline panel, expand the Miscellaneous category in the Properties panel.

  6. Click the New button next to the Document property. The Document property is populated with a FlowDocument object, and the subproperty editor for the FlowDocument opens. You can expand and collapse the subproperty editor. The Document property can contain only one FlowDocument.

    NoteNote

    Properties that will display a subproperty editor are typically identified by a New button next to them, and an expander arrow Cc294699.6375953d-074c-421a-bbb3-6f5055b67b64(en-us,Expression.40).png (if the property has content). If the property has default subproperties associated with them, a drop-down arrow will also appear next to the property. For example, the BitmapEffect property provides a drop-down list that includes the BevelBitmapEffect, BlurBitmapEffect, and other subproperties that you can select from.

  7. In the subproperty editor for the Document property, click the Edit items in this collection button next to the Blocks (Collection) property. The collection editor opens for the Blocks property.

    NoteNote

    Properties that will display a collection editor are typically identified by the word (Collection) next to the property name, and by an Edit items in this collection button.

    The collection editor of the Blocks subproperty

    Cc294699.7becf751-36c9-49f0-a8bd-6308397e82ea(en-us,Expression.40).png
  8. In the collection editor for the Blocks subproperty, click the Add another item button. The Select Object window appears, from which you can select any Windows Presentation Foundation (WPF) object.

  9. In the Search text box, type Paragraph to quickly locate the Paragraph class. Select Paragraph from the list under System.Windows.Documents, and then click OK. The Select Object window closes, and a Paragraph item is added to the collection editor at index 0. The properties of the Paragraph object are displayed on the right side.

    NoteNote

    It can be difficult to understand which objects are valid for a given collection. For collection properties of common controls (such as the Items collection property of the ListBox control), the collection editor provides a drop-down list of suggested items in addition to the Add another item button. However, for less common controls (such as the FlowDocumentReader control), if might help you understand which objects are valid for the collection to view the MSDN documentation for the control type. For example, in the Flow Related Classes section of the Flow Document Overview Cc294699.xtlink_newWindow(en-us,Expression.40).png on MSDN Cc294699.xtlink_newWindow(en-us,Expression.40).png, a diagram shows the structure of flow document controls. From that diagram, you can see that the Blocks property can contain a Paragraph, Section, List, Table, and/or a BlockUIContainer object. In the following steps, you will add a Run element to the Inlines collection property of the Paragraph object.

  10. In the Properties window of the Paragraph object, click the Edit items in this collection button next to the Inlines property. The collection editor switches to the scope of the Inlines property.

  11. Click the Add another item button, and then select the Run class from the Select Object window. A Run object has been added to the collection editor at index 0.

  12. In the Properties window of the Run object, add content by typing in the Text property. You can also use some of the properties of the Brushes and Text categories to style the text. Other properties are disabled because they have to be set at the level of the FlowDocumentViewer control.

    The collection editor of the Inlines property after adding a Run object and editing the Text

    Cc294699.36430950-044e-44e8-a70f-c5fa9fc7ddde(en-us,Expression.40).png
  13. Click OK to exit the collection editor for the Inlines property, and then click OK to exit the collection editor of the Blocks property. The text that you entered in the previous step is displayed in the FlowDocumentViewer control.

    important noteImportant

    Do not click the New button next to the Document property of the FlowDocumentViewer object unless you want to delete the content that you just created, because the Document property can contain only one FlowDocument object. Unless a property name includes the word (Collection), the property can contain only a single object.

NoteNote

If you are editing a FlowDocumentScrollViewer or a RichTextBox object, you can use the Microsoft Expression Blend text editor, which can be accessed by selecting the object and then pressing F2. For more information, see Edit text. If you are editing a DocumentViewer or a FlowDocumentPageViewer object, content is added programmatically.

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.
Show:
© 2014 Microsoft