Span Span Span Span Class
Definition
public : class Span : Inline, ISpanpublic class Span : Inline, ISpanPublic Class Span Inherits Inline Implements ISpan// This API is not available in Javascript.
<Span .../>
-or-
<Span ...>
oneOrMoreInlines
</Span>
-or-
<Span ...>
mixedContent
</Span>
- Inheritance
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Inherited Members
Inherited properties
Inherited events
Inherited methods
Remarks
You can use Span as an object element in XAML to enclose text. This enables a similar usage to how you might use thespan tag in HTML. For this usage you'd set the attributes that are supported by TextElement such as FontSize or FontFamily, so that you can apply these text formatting decisions to the enclosed span of text. Run has similar functionality of applying TextElement properties to a range of text, but Run doesn't support mixed content (its Run.Text XAML content property can only contain text, not mixed content and further inlines).
Span supports mixed content if you set the content in XAML. What this means is that you can mix Inline tags such as Run, Bold and so on with XAML text content (plain text), with no restrictions on the order in which tags versus text must appear. All text, whether plain text or as enclosed in an Inline tag, renders in the order that the text is defined in the mixed content. For example, this is legal XAML:
<RichTextBlock>
<Paragraph>
<Span>This is <Bold>mixed content</Bold> with multiple text areas <Italic> and inlines</Italic>.</Span>
</Paragraph>
</RichTextBlock>
When mixed content is parsed from XAML, and the text object model is examined at run time, any text area that came from the plain text generates a Run object at the appropriate reading-order position in the InlineCollection collection class that enables run-time access. That Run element contains the text but otherwise has no properties set.
Note
Placing XAML content whether tags or text directly within a Span element is supported because Span denotes that its Inlines property is the XAML content property. For more info on XAML content properties, see "XAML content properties" section of XAML syntax guide.
Span elements are typically used as elements within an InlineCollection, either as child elements of a Paragraph (becomes part of Paragraph.Inlines ) or as the content of another Span (becomes part of Span.Inlines ).
Span derived classes
Span is the parent class for several derived classes that define an inline text region with a particular formatting convention:
- Bold
- Hyperlink
- Italic
- Underline Hyperlink enables a click behavior that navigates to the NavigateUri. The other Span derived classes can be thought of as class-specific decorations to the text and don't otherwise add interaction.
Constructors
Properties
Inlines Inlines Inlines Inlines
Gets an InlineCollection containing the top-level inline elements that include the contents of Span.
public : InlineCollection Inlines { get; set; }public InlineCollection Inlines { get; set; }Public ReadWrite Property Inlines As InlineCollection// This API is not available in Javascript.
<Span ...>
oneOrMoreInlines
</Span>
-or-
<Span ...>
mixedContent
</Span>
An InlineCollection containing the inline elements that include the contents of the Span. This property has no default value.
Remarks
Hyperlink has restrictions on the content that can exist in its Inlines colllection. Specifically, a Hyperlink only permits Run and other Span types that aren't another Hyperlink. InlineUIContainer can't be in the Inlines colllection of a Hyperlink. Attempting to add restricted content throws an invalid args exception or XAML parse exception.