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)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[ContentWrapperAttribute(typeof(Run))] 
[ContentWrapperAttribute(typeof(InlineUIContainer))] 
public class InlineCollection : TextElementCollection<Inline>, IList, ICollection, IEnumerable
/** @attribute ContentWrapperAttribute(System.Windows.Documents.Run) */ 
/** @attribute ContentWrapperAttribute(System.Windows.Documents.InlineUIContainer) */ 
public class InlineCollection extends TextElementCollection<Inline> implements IList, ICollection, 
	IEnumerable
ContentWrapperAttribute(System.Windows.Documents.Run) 
ContentWrapperAttribute(System.Windows.Documents.InlineUIContainer) 
public class InlineCollection extends TextElementCollection<Inline> implements IList, ICollection, 
	IEnumerable
You cannot use this managed class in XAML.

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();

System.Object
   System.Windows.Documents.TextElementCollection
    System.Windows.Documents.InlineCollection

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Community Additions

ADD
Show:
© 2014 Microsoft