Run Run Run Class

Represents a discrete section of formatted or unformatted text.

Syntax

Declaration

public sealed class Runpublic sealed class RunPublic NotInheritable Class Run
<Run .../>
-or-
<Run ...>text</Run>

Inheritance Hierarchy

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 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 summary

Initializes a new instance of the Run class.

Properties summary

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

Identifies the FlowDirection dependency property.

Gets or sets the text contents of the Run.

Constructors

  • Run()
    Run()
    Run()
    Run()

    Initializes a new instance of the Run class.

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

Properties

  • FlowDirection
    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 FlowDirectionpublic FlowDirection FlowDirection { get; set; }
    <Run FlowDirection="LeftToRight"/>
    -or-
    <Run FlowDirection="RightToLeft"/>
    

    Property Value

  • FlowDirectionProperty
    FlowDirectionProperty
    FlowDirectionProperty
    FlowDirectionProperty

    Identifies the FlowDirection dependency property.

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

    Property Value

  • Text
    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 stringpublic string Text { get; set; }
    <Run Text="text"/>
    

    Property Value

    • string
      string
      string

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

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute
Windows.UI.Xaml.Markup.ContentPropertyAttribute

Details

Assembly

Windows.UI.Xaml.Documents.dll