This topic has not yet been rated - Rate this topic

InlineCollection Class

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

System.Object
  System.Windows.Documents.TextElementCollection<Inline>
    System.Windows.Documents.InlineCollection

Namespace:  System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)
[ContentWrapperAttribute(typeof(Run))]
[WhitespaceSignificantCollectionAttribute]
[ContentWrapperAttribute(typeof(InlineUIContainer))]
public class InlineCollection : TextElementCollection<Inline>, 
	IList, ICollection, IEnumerable

The InlineCollection type exposes the following members.

  Name Description
Public property Count Gets the number of items currently in the collection. (Inherited from TextElementCollection<TextElementType>.)
Public property FirstInline Gets the first Inline element within this instance of InlineCollection.
Public property IsReadOnly Gets a value that indicates whether or not the collection is read-only. (Inherited from TextElementCollection<TextElementType>.)
Public property LastInline Gets the last Inline element within this instance of InlineCollection.
Top
  Name Description
Public method Add(TextElementType) Appends a specified item to the collection. (Inherited from TextElementCollection<TextElementType>.)
Public method Add(String) Adds an implicit Run element with the given text, supplied as a String.
Public method Add(UIElement) Adds an implicit InlineUIContainer with the supplied UIElement already in it.
Public method AddRange Appends a specified range of items to the collection. (Inherited from TextElementCollection<TextElementType>.)
Public method Clear Clears all items from the collection. (Inherited from TextElementCollection<TextElementType>.)
Public method Contains Queries for the presence of a specified item in the collection. (Inherited from TextElementCollection<TextElementType>.)
Public method CopyTo Copies 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 method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetEnumerator Returns an enumerator for the contents of the collection. (Inherited from TextElementCollection<TextElementType>.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method InsertAfter Inserts a specified item in the collection after a specified collection item. (Inherited from TextElementCollection<TextElementType>.)
Public method InsertBefore Inserts a specified item in the collection before a specified collection item. (Inherited from TextElementCollection<TextElementType>.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Remove Removes a specified item from the collection. (Inherited from TextElementCollection<TextElementType>.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Public Extension Method AsParallel Enables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension Method AsQueryable Converts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension Method Cast<TResult> Converts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension Method OfType<TResult> Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top
  Name Description
Explicit interface implemetation Private method ICollection.CopyTo Copies 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 implemetation Private property ICollection.Count Gets the number of elements contained in the ICollection. Use the type-safe Count property instead. (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private property ICollection.IsSynchronized Gets a value indicating whether access to the ICollection is synchronized (thread safe). (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private property ICollection.SyncRoot Gets an object that can be used to synchronize access to the ICollection. (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private method IEnumerable.GetEnumerator Returns an enumerator that iterates through a collection. Use the type-safe GetEnumerator method instead. (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private method IList.Add Adds an item to the IList. Use the type-safe Add method instead. (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private method IList.Clear This 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 implemetation Private method IList.Contains Determines whether the IList contains a specific value.. Use the type-safe Contains method instead. (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private method IList.IndexOf Determines the index of a specific item in the IList. (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private method IList.Insert Inserts an item to the IList at the specified index. Use the type-safe InsertAfter or InsertBefore methods instead. (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private property IList.IsFixedSize Gets a value indicating whether the IList has a fixed size. (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private property IList.IsReadOnly Gets a value indicating whether the IList is read-only. (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private property IList.Item Gets or sets the element at the specified index. (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private method IList.Remove Removes the first occurrence of a specific object from the IList. Use the type-safe Remove method instead. (Inherited from TextElementCollection<TextElementType>.)
Explicit interface implemetation Private method IList.RemoveAt Removes 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, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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)
Community Content Add
Annotations FAQ