TextRun Class
Represents a sequence of characters that share a single property set.
Assembly: PresentationCore (in PresentationCore.dll)
System.Windows.Media.TextFormatting::TextRun
System.Windows.Media.TextFormatting::TextCharacters
System.Windows.Media.TextFormatting::TextEmbeddedObject
System.Windows.Media.TextFormatting::TextEndOfLine
System.Windows.Media.TextFormatting::TextEndOfSegment
System.Windows.Media.TextFormatting::TextHidden
System.Windows.Media.TextFormatting::TextModifier
| Name | Description | |
|---|---|---|
![]() | TextRun() | Creates an instance of a TextRun object. |
| Name | Description | |
|---|---|---|
![]() | CharacterBufferReference | Gets a reference to the text run character buffer. |
![]() | Length | Gets the number of characters in the text run. |
![]() | Properties | Gets the set of text properties that are shared by every character in the text run, such as typeface or foreground brush. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | MemberwiseClone() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
A text run is a sequence of characters sharing a single property set. Any change to the format, such as font style, foreground color, font family, or any other formatting effect, breaks the text run. The following example illustrates how changes in formatting to a text string results in a series of text runs—each text run has a common set of formatting properties.
The TextRun class is the root of a type hierarchy representing several types of text content processed by TextFormatter. Each class that is derived from TextRun represents a distinct type of text content.
Class | Description |
|---|---|
TextRun | Root of the hierarchy. Defines a group of characters that share the same set of character properties. |
Defines a collection of character glyphs from a distinct physical typeface. | |
Defines a type of text content in which measuring, hit testing, and drawing of the entire content is done as a distinct entity. An example of this type of content is a button in the middle of the line of text. | |
Defines a line-break character code. | |
Defines a paragraph-break character code. Derives from TextEndOfLine. | |
Defines a segment break marker. | |
Defines a range of non-visible characters. | |
Defines the beginning of a modification scope. |
In the following example, an override for the GetTextRun method is implemented.
Available since 3.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


