Windows.UI.Xaml.Documents.Run
June 20, 2025 ยท View on GitHub
-description
Represents a discrete section of formatted or unformatted text.
-xaml-syntax
<Run .../>
-or-
<Run ...>text</Run>
-remarks
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 details on the TextBlock and RichTextBlock controls, see:
-examples
Each of the following examples render the same result. However, setting the Text property directly on the TextBlock provides the best performance.
<!-- Set the TextBlock.Text property directly 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 directly 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);