Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

BlockCollection Class

Represents a collection of Block elements. BlockCollection defines the allowable child content of the FlowDocument, Section, ListItem, TableCell, Floater, and Figure elements.

Namespace:  System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)
type BlockCollection =  
    class 
        inherit TextElementCollection<Block>
    end

The BlockCollection type exposes the following members.

  NameDescription
Public propertyCountGets the number of items currently in the collection. (Inherited from TextElementCollection(TextElementType).)
Public propertyFirstBlockGets the first Block element within this instance of BlockCollection.
Public propertyIsReadOnlyGets a value that indicates whether or not the collection is read-only. (Inherited from TextElementCollection(TextElementType).)
Public propertyLastBlockGets the last Block element within this instance of BlockCollection.
Top
  NameDescription
Public methodAddAppends a specified item to the collection. (Inherited from TextElementCollection(TextElementType).)
Public methodAddRangeAppends a specified range of items to the collection. (Inherited from TextElementCollection(TextElementType).)
Public methodClearClears all items from the collection. (Inherited from TextElementCollection(TextElementType).)
Public methodContainsQueries for the presence of a specified item in the collection. (Inherited from TextElementCollection(TextElementType).)
Public methodCopyToCopies the contents of the collection and inserts them into a specified array starting at a specified index position in the array. (Inherited from TextElementCollection(TextElementType).)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an enumerator for the contents of the collection. (Inherited from TextElementCollection(TextElementType).)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInsertAfterInserts a specified item in the collection after a specified collection item. (Inherited from TextElementCollection(TextElementType).)
Public methodInsertBeforeInserts a specified item in the collection before a specified collection item. (Inherited from TextElementCollection(TextElementType).)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemoveRemoves a specified item from the collection. (Inherited from TextElementCollection(TextElementType).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Explicit interface implemetationPrivate methodICollection.CopyToCopies the elements of the ICollection to an Array, starting at a particular Array index.. Use the type-safe CopyTo method instead. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate propertyICollection.CountGets the number of elements contained in the ICollection. Use the type-safe Count property instead. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedGets a value indicating whether access to the ICollection is synchronized (thread safe). (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate propertyICollection.SyncRootGets an object that can be used to synchronize access to the ICollection. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate methodIEnumerable.GetEnumeratorReturns an enumerator that iterates through a collection. Use the type-safe GetEnumerator method instead. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate methodIList.AddAdds an item to the IList. Use the type-safe Add method instead. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate methodIList.ClearThis type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. Use the type-safe Clear method instead. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate methodIList.ContainsDetermines whether the IList contains a specific value.. Use the type-safe Contains method instead. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate methodIList.IndexOfDetermines the index of a specific item in the IList. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate methodIList.InsertInserts an item to the IList at the specified index. Use the type-safe InsertAfter or InsertBefore methods instead. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate propertyIList.IsFixedSizeGets a value indicating whether the IList has a fixed size. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate propertyIList.IsReadOnlyGets a value indicating whether the IList is read-only. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate propertyIList.ItemGets or sets the element at the specified index. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate methodIList.RemoveRemoves the first occurrence of a specific object from the IList. Use the type-safe Remove method instead. (Inherited from TextElementCollection(TextElementType).)
Explicit interface implemetationPrivate methodIList.RemoveAtRemoves the IList item at the specified index. (Inherited from TextElementCollection(TextElementType).)
Top

BlockCollection creation is only permitted inside an element that owns a BlockCollection, such as a FlowDocument or TextElement. As such, a BlockCollection cannot be instantiated directly and has no default or overloaded constructor.

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 BlockCollection. Flow content elements that feature a Blocks property include:

These examples happen to use Section as the flow content element, but these techniques are applicable to all elements that host a flow content element collection.

The following example creates a new Section and then uses the Add method to add a new Paragraph to the Section contents.

No code example is currently available or this language may not be supported.

The following example creates a new Paragraph element and inserts it at the beginning of the Section.

No code example is currently available or this language may not be supported.

The following example gets the number of top-level Block elements contained in the Section.

No code example is currently available or this language may not be supported.

The following example deletes the last Block element in the Section.

No code example is currently available or this language may not be supported.

The following example clears all of the contents (Block elements) from the Section.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.