Share via


Inlines Object

Represents a collection of Run and LineBreak objects.

XAML
Cannot be used in XAML; see Remarks.
Scripting
Cannot explicitly create a new Inlines, reference to existing collection only.

Properties

Count, Name

Methods

Add, Clear, Equals, FindName, GetHost, GetItem, GetValue, Insert, Remove, RemoveAt, SetValue

Remarks

Inlines defines no methods or properties beyond the basic Collection methods and properties. Methods such as Add or GetItem will expect or return objects that are of type Run or LineBreak.

This is the collection that underlies TextBlock.Inlines, which is the content property of a TextBlock. However, Inlines cannot be used in XAML syntax as an object element. An Inlines collection is implicitly created by XAML parsing and is available if you examine the runtime object tree through scripting, but explicit uses in XAML are disallowed. TextBlock.Inlines is marginally permitted in XAML. The marginal aspect is because even XML white space is interpreted as possible content of the TextBlock, and if any content is detected the parser will populate the implicit Inlines collection using that content as an initial Run. Defining TextBlock.Inlines thereafter is thus interpreted as an attempt to set Inlines twice. Therefore the only way to specify TextBlock.Inlines would be if there were was no white space at all between the <TextBlock> object element and <TextBlock.Inlines> object element.

The XAML syntax for properties that use Inlines is an example of an implicit collection syntax, where you omit an actual Inlines object element. Instead, you generally include one or more inline types (Run and LineBreak elements) as child elements of a TextBlock. For more information about XAML implicit collection syntax, see XAML Syntax Overview. In addition to the implicit collection syntax of inlines, TextBlock also supports setting content as inner text, or by specifically setting the value of Text with a string. For details, see TextBlock.

See Also

Text and Fonts Overview
Collection
Run
LineBreak