This documentation is archived and is not being maintained.

Span.Inlines Property

Gets an InlineCollection containing the top-level Inline elements that comprise the contents of the Span.

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

public InlineCollection Inlines { get; }
  <InlineCollection .../>

Property Value

Type: System.Windows.Documents.InlineCollection
An InlineCollection containing the Inline elements that comprise the contents of the Span.
This property has no default value.

Use the InlineCollection returned by this property to enumerate or manipulate the contents of a Span element.

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.


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


Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5, 3.0