Export (0) Print
Expand All

InlineCollection Class

Represents a collection of Inline elements. InlineCollection defines the allowable child content of the Paragraph, Span, and TextBlock elements.

Namespace:  System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)

[ContentWrapperAttribute(typeof(Run))]
[ContentWrapperAttribute(typeof(InlineUIContainer))]
[WhitespaceSignificantCollectionAttribute]
public class InlineCollection : TextElementCollection<Inline>, 
	IList, ICollection, IEnumerable

The InlineCollection type exposes the following members.

  NameDescription
Public propertyCountGets the number of items currently in the collection. (Inherited from TextElementCollection<TextElementType>.)
Public propertyFirstInlineGets the first Inline element within this instance of InlineCollection.
Public propertyIsReadOnlyGets a value that indicates whether or not the collection is read-only. (Inherited from TextElementCollection<TextElementType>.)
Public propertyLastInlineGets the last Inline element within this instance of InlineCollection.
Top

  NameDescription
Public methodAdd(TextElementType)Appends a specified item to the collection. (Inherited from TextElementCollection<TextElementType>.)
Public methodAdd(String)Adds an implicit Run element with the given text, supplied as a String.
Public methodAdd(UIElement)Adds an implicit InlineUIContainer with the supplied UIElement already in it.
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
Public Extension MethodAsParallelEnables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodCast<TResult>Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodOfType<TResult>Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
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

InlineCollection creation is only permitted inside an element that owns an InlineCollection, such as a TextBlock or a Paragraph. As such, an InlineCollection 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 inline flow content elements (and containers of such elements, such as TextBlock) through the Inlines property. This property is used to add and remove items from InlineCollection. Flow content elements that feature an Inlines property include:

These examples happen to use Span as the flow content element, but these techniques are applicable to all elements or controls that host an InlineCollection collection.

The following example creates a new Span object, and then uses the Add method to add two text runs as content children of the Span.

Span spanx = new Span();
spanx.Inlines.Add(new Run("A bit of text content..."));
spanx.Inlines.Add(new Run("A bit more text content..."));

The following example creates a new Run element and inserts it at the beginning of the Span.

Run runx = new Run("Text to insert...");
spanx.Inlines.InsertBefore(spanx.Inlines.FirstInline, runx);

The following example gets the number of top-level Inline elements contained in the Span.

int countTopLevelInlines = spanx.Inlines.Count;

The following example deletes the last Inline element in the Span.

spanx.Inlines.Remove(spanx.Inlines.LastInline);

The following example clears all of the contents (Inline elements) from the Span.

spanx.Inlines.Clear();

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.
Show:
© 2014 Microsoft