Run Run Run Class

Definition

Represents a discrete section of formatted or unformatted text.

public sealed class Run : Inline, IRunpublic sealed class Run : Inline, IRunPublic NotInheritable Class Run Inherits Inline Implements IRun
<Run .../>
-or-
<Run ...>text</Run>
Inheritance
Attributes
Windows 10 requirements
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

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

Examples

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);

Constructors

Run() Run() Run()

Initializes a new instance of the Run class.

public Run()public Run()Public Sub New()
Attributes

Properties

FlowDirection FlowDirection FlowDirection

Gets or sets the direction that text and other user interface elements flow within the Run element that controls their layout.

public FlowDirection FlowDirection { get; set; }public FlowDirection FlowDirection { get; set; }Public ReadWrite Property FlowDirection As FlowDirection
<Run FlowDirection="LeftToRight"/>
-or-
<Run FlowDirection="RightToLeft"/>
Value
FlowDirection FlowDirection FlowDirection

The direction that text and other user interface (UI) elements flow within the Run element. The default value is LeftToRight.

Attributes

FlowDirectionProperty FlowDirectionProperty FlowDirectionProperty

Identifies the FlowDirection dependency property.

public static DependencyProperty FlowDirectionProperty { get; }public static DependencyProperty FlowDirectionProperty { get; }Public Static ReadOnly Property FlowDirectionProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier of the FlowDirection dependency property.

Attributes

Text Text Text

Gets or sets the text contents of the Run.

public string Text { get; set; }public string Text { get; set; }Public ReadWrite Property Text As string
<Run Text="text"/>
Value
string string string

A string that specifies the text contents of the Run. The default is String.Empty.

Attributes