Bagikan melalui


Inlines

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Represents a collection of Run and LineBreak objects.

Syntax Notes

You cannot instantiate Inlines, you must get an instance from an existing property value.

Managed Equivalent

InlineCollection

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 of type Run or LineBreak.

Inlines represents the collection that underlies the TextBlock.Inlines property, which is the content property of a TextBlock object. However, you cannot use Inlines in XAML syntax as an object element. XAML parsing implicitly creates an Inlines collection, which is available if you examine the runtime object tree through scripting; 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; if any content is detected, the parser will populate the implicit Inlines collection by using that content as an initial Run object. Defining TextBlock.Inlines, thereafter, is interpreted as an attempt to set TextBlock.Inlines twice. 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 implicit collection syntax, in which 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. In addition to the implicit collection syntax of Inlines, TextBlock also supports setting content as inner text, or setting content by specifically setting the value of the Text (TextElement) property with a string. For more information, see the TextBlock object.

See Also

Reference

Run