Freigeben über


Run.Text Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the text contents of the Run.

Namespace:  System.Windows.Documents
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property Text As String
public string Text { get; set; }
<Run ...>text</Run>
<Run Text="text"/>

Property Value

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

Remarks

Any leading or trailing white space is not preserved when you set the Text property in XAML or in code.

When you set text in a TextBlock or a Run, it is not necessary to explicitly specify the Text property in XAML. Instead, you can put the text directly within the element, as shown in the following example.

<TextBlock>Hello, world!</TextBlock>
<TextBlock>
  <TextBlock.Inlines>
    <Run>Hello again, world!</Run>
  </TextBlock.Inlines>
</TextBlock>

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.