Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-manipulate-flow-content-elements-through-the-blocks-property.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

4.4 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Manipulate Flow Content Elements through the Blocks Property 03/30/2017
csharp
vb
documents [WPF], manipulating flow content elements through Blocks property
flow content elements [WPF], manipulating through Blocks property
properties [WPF], Blocks [WPF], manipulating flow content elements
Blocks property [WPF], manipulating flow content elements
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.

Example

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]

Example

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]

Example

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]

Example

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]

Example

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