Using the sub-property and collection editors
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 sub-property editor to modify these values.
The following procedure uses the sub-property and collection editors to show you how to add content to a FlowDocumentReader control.
|You do not need to use this procedure to modify the text in a FlowDocumentScrollViewer controlyou can use the procedures in Edit text, Format text, and the other topics that are listed in the "How to" section in Text.|
To add content to a FlowDocumentReader control
- The FlowDocumentReader control is available from the Asset Library. In the Toolbox, click the Asset Library button .
- Select the Show All checkbox to see all of the available controls.
- In the Controls tab, select System Controls
(default), and then select the FlowDocumentReader control.
A generic icon appears above the Asset Library button on the Toolbox, selected and ready to be added to the artboard.
- Draw a FlowDocumentReader on the artboard.
A FlowDocumentReader control drawn on the artboard
- With the FlowDocumentReader object selected under Objects and Timeline, expand the Miscellaneous category in the Properties panel.
- Click the New button next to the Document property.
The Document property is populated with a FlowDocument object, and the sub-property editor for the FlowDocument opens. You can expand and collapse the sub-property editor. The Document property can contain only one FlowDocument.
Properties that will display a sub-property editor are typically identified by a New button next to them, and an expander arrow (if the property has content).
If the property has default sub-properties associated with them, there will also be a dropdown arrow next to the property. For example, the BitmapEffect property provides a dropdown list that includes the BevelBitmapEffect, BlurBitmapEffect, and other sub-properties that you can choose from.
The sub-property editor of the Document property showing the Blocks collection property
- In the sub-property 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.
Properties that will display a collection editor are typically identified by the word (Collection) next to the property name, and an Edit items in this collection button.
The collection editor of the Blocks sub-property
- In the collection editor for the Blocks sub-property, click the Add
another item button.
The Select Object window appears, from which you can select any Windows Presentation Foundation (WPF) object.
- In the Search textbox, 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 has been added to the collection editor at index 0. The properties of the Paragraph object are displayed on the right side.
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 as well as the Add another item button. However, in the case of less common controls (such as the FlowDocumentReader control), you can view the MSDN documentation for the control type to understand what elements are valid for the collection. For example, in the Flow Related Classes section of the Flow Document Overview on MSDN, there is a diagram that 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.
- 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.
- 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.
- 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
category to style the text. Other properties are disabled because they need to
be set at the level the FlowDocumentViewer control.
The collection editor of the Inlines property after adding a Run object and editing the Text
- 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.
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 only contain one FlowDocument object. Unless a property name includes the word (Collection), the property can only contain a single object.
|If you are editing a FlowDocumentScrollViewer or a RichTextBox object,
you can use the Expression Blend text editor which is accessible by
selecting the object and then pressing F2. For more information, see
Edit text in this User Guide.
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 can be downloaded from Windows SDK .NET Framework 3.0 Samples.