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.

Cc294699.alert_note(en-us,Expression.10).gifNote:

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 Text and typography.

  1. The FlowDocumentReader control is available from the Asset Library. In the Toolbox, click the Asset Library button Cc294699.0224cabd-5da1-4e01-bddd-4a647401a098(en-us,Expression.10).png.

  2. Select the Show All check box to see all the available controls.

  3. In the Controls tab, select System Controls (default), and then select the FlowDocumentReader control. A generic icon appears above the Asset Library button in the Toolbox, 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.10).png
  5. With the FlowDocumentReader object selected under Objects and Timeline, 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.

    Cc294699.alert_note(en-us,Expression.10).gifNote:

    Properties that will display a subproperty editor are typically identified by a New button next to them, and an expander arrow Cc294699.b21226d8-0f6c-454b-98fb-1b8e22f45c99(en-us,Expression.10).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.

    The subproperty editor of the Document property showing the Blocks collection property

    Cc294699.421a7657-c71e-44de-ac91-bbc8bb64800d(en-us,Expression.10).png
  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.

    Cc294699.alert_note(en-us,Expression.10).gifNote:

    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.10).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.

    Cc294699.alert_note(en-us,Expression.10).gifNote:

    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 elements 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 on MSDN, 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 element. 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.10).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.

    Cc294699.alert_caution(en-us,Expression.10).gifImportant:

    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.

Cc294699.alert_note(en-us,Expression.10).gifNote:

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. For more information, see Flow Document Overview and Documents in Windows Presentation Foundation on MSDN. Also see the DocumentViewer Samples and FlowDocumentReader Samples that you can download from Windows SDK .NET Framework 3.0 Samples.

Community Additions

ADD
Show:
© 2014 Microsoft