-api-id | -api-type |
---|---|
T:Windows.UI.Xaml.Documents.Run |
winrt class |
Represents a discrete section of formatted or unformatted text.
<Run .../>
-or-
<Run ...>text</Run>
A Run represents a discrete section of formatted or unformatted text and can be used in a TextBlock or RichTextBlock. You can place multiple Run elements inside of a Span.
When you use a TextBlock, set the TextBlock.Text property directly for best performance. You typically use the Run element only when you want to format a discrete section of text within the TextBlock.
For more examples, see
Each example shown here renders the same result. However, setting the Text property directly on the TextBlock has the best performance.
<!-- Set the TextBlock.Text property directy for best performance. -->
<TextBlock Text="This is some text."/>
<TextBlock><Run>This is some text.</Run></TextBlock>
<TextBlock><Run Text="This is some text."></Run></TextBlock>
// Set the TextBlock.Text property directy for best performance.
TextBlock textblock = new TextBlock();
textblock.Text = "This is some text.";
TextBlock textblock = new TextBlock();
Run run = new Run();
run.Text = "This is some text.";
textblock.Inlines.Add(run);