* Suggestion/warning fixes for US-1889327. * Updated H2s. * Minor content edit. * Review edits. * Minor edits. * Update dotnet-desktop-guide/framework/wpf/advanced/localization-attributes-and-comments.md Co-authored-by: Andy (Steve) De George <[email protected]>
4.7 KiB
title, ms.date, ms.custom, description, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | ms.custom | description | dev_langs | helpviewer_keywords | ms.assetid | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| How to: Manipulate Flow Content Elements through the Blocks Property | 03/30/2017 | devdivchpfy22 | Learn how to manipulate Flow Content Elements through the Blocks property. |
|
|
aeda4ece-b979-4818-a093-ef938e908751 |
How to: Manipulate Flow Content Elements through the Blocks Property
These examples demonstrate some of the more common operations that can be performed on flow content elements through the Blocks property. This property is used to add and remove items from xref:System.Windows.Documents.BlockCollection. Flow content elements that feature a Blocks property include:
These examples happen to use xref:System.Windows.Documents.Section as the flow content element, but these techniques are applicable to all elements that host a flow content element collection.
Create a new Section
The following example creates a new xref:System.Windows.Documents.Section and then uses the Add method to add a new Paragraph to the Section contents.
[!code-csharpFlowDocumentSnippets#_SectionBlocksAdd] [!code-vbFlowDocumentSnippets#_SectionBlocksAdd]
Create a new Paragraph element
The following example creates a new xref:System.Windows.Documents.Paragraph element and inserts it at the beginning of the xref:System.Windows.Documents.Section.
[!code-csharpFlowDocumentSnippets#_SectionBlocksInsert] [!code-vbFlowDocumentSnippets#_SectionBlocksInsert]
Get the top-level Block elements in the Section
The following example gets the number of top-level xref:System.Windows.Documents.Block elements contained in the xref:System.Windows.Documents.Section.
[!code-csharpFlowDocumentSnippets#_SectionBlocksCount] [!code-vbFlowDocumentSnippets#_SectionBlocksCount]
Delete the last Block element in the Section
The following example deletes the last xref:System.Windows.Documents.Block element in the xref:System.Windows.Documents.Section.
[!code-csharpFlowDocumentSnippets#_SectionBlocksRemoveLast] [!code-vbFlowDocumentSnippets#_SectionBlocksRemoveLast]
Clear all the Block element content from the Section
The following example clears all of the contents (xref:System.Windows.Documents.Block elements) from the xref:System.Windows.Documents.Section.
[!code-csharpFlowDocumentSnippets#_SectionBlocksClear] [!code-vbFlowDocumentSnippets#_SectionBlocksClear]
See also
- xref:System.Windows.Documents.BlockCollection
- xref:System.Windows.Documents.InlineCollection
- xref:System.Windows.Documents.ListItemCollection
- Flow Document Overview
- Manipulate a Table's Row Groups through the RowGroups Property
- Manipulate a Table's Columns through the Columns Property
- Manipulate a Table's Row Groups through the RowGroups Property