TextPrimitive
Represents a primitive element that renders text content with advanced formatting, layout, and styling capabilities.
Definition
Namespace:Telerik.WinControls.Primitives
Assembly:Telerik.WinControls.dll
Syntax:
public class TextPrimitive : BasePrimitive, IDisposable, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IStylableNode, IPrimitive, ITextProvider, ITextPrimitive
Inheritance: objectDisposableObjectRadObjectRadElementVisualElementBasePrimitiveTextPrimitive...
Derived Classes:
Implements:
Inherited Members
Constructors
public TextPrimitive()
Fields
public static RadProperty AutoEllipsisProperty
public static RadProperty DisabledTextRenderingHintProperty
public static RadProperty FlipTextProperty
public static RadProperty LineLimitProperty
public static RadProperty MeasureTrailingSpacesProperty
public static RadProperty ShadowProperty
public static RadProperty ShowKeyboardCuesProperty
public static RadProperty TextAlignmentProperty
public static RadProperty TextOrientationProperty
public static RadProperty TextProperty
public static RadProperty TextRenderingHintProperty
public static RadProperty TextWrapProperty
public static RadProperty UseMnemonicProperty
Properties
Gets or sets a value indicating whether the additional label text is to be indicated by an ellipsis.
public bool AutoEllipsis { get; set; }
true if the additional label text is to be indicated by an ellipsis otherwise, false. Default value is true.
Implements:
[Browsable(false)]
public Color CachedForeColor { get; set; }
Gets or sets the text rendering hint used when this primitive is disabled.
public virtual TextRenderingHint DisabledTextRenderingHint { get; set; }
A TextRenderingHint value that specifies the text rendering quality for disabled state. The default value is AntiAliasGridFit.
This property allows for different text rendering quality when the primitive is disabled, often providing a softer appearance that visually indicates the disabled state.
public bool DisableHTMLRendering { get; set; }
Gets or sets a value indicating whether the text should be flipped (mirrored) during rendering.
public bool FlipText { get; set; }
true if the text should be flipped; otherwise, false. The default value is false.
Implements:
Text flipping creates a mirror image of the text, which can be useful for special visual effects or when implementing right-to-left language support with custom rendering requirements. This property works in conjunction with TextOrientation for advanced text transformations.
Gets a value indicating whether this primitive contains any displayable content.
public override bool IsEmpty { get; }
true if the Text property is null or empty; otherwise, false.
Overrides:
This property is used by the layout system and rendering engine to optimize operations by skipping empty text primitives during layout calculations and paint operations.
Gets or sets a value indicating whether text rendering is limited to a specific number of lines.
public bool LineLimit { get; set; }
true if line limiting is enabled; otherwise, false.
When enabled, this property works in conjunction with other text formatting options to control the maximum number of lines displayed, providing better control over text layout in constrained spaces.
Gets or sets a value indicating whether trailing spaces at the end of each line are included in text measurement calculations.
public bool MeasureTrailingSpaces { get; set; }
true to include trailing spaces in text measurement; otherwise, false.
The default value is true.
Implements:
By default, the boundary rectangle returned by text measurement methods excludes trailing spaces
at the end of each line. Setting this property to true includes that space in measurement,
which can be important for precise layout calculations and text alignment scenarios.
This property is particularly useful when working with text that needs to maintain exact spacing or when implementing custom text layout algorithms.
Gets or sets the shadow settings.
[TypeConverter("Telerik.WinControls.UI.Design.ShadowSettingsConverter, Telerik.WinControls.UI.Design, Version=2026.2.702.48, Culture=neutral, PublicKeyToken=5bb2a467cbec794e")]
public ShadowSettings Shadow { get; set; }
Implements:
Gets or sets a value indicating whether if the keyboard accelerators are visible.
public bool ShowKeyboardCues { get; set; }
true if if the keyboard accelerators are visible otherwise, false.
Implements:
Gets or sets a value indicating whether this primitive stretches horizontally within its parent layout.
public override bool StretchHorizontally { get; set; }
true if the primitive should stretch horizontally; otherwise, false.
The default value is false.
Overrides:
For text primitives, horizontal stretching is typically disabled to maintain text layout integrity and prevent unwanted text spacing or alignment issues.
Gets or sets a value indicating whether this primitive stretches vertically within its parent layout.
public override bool StretchVertically { get; set; }
true if the primitive should stretch vertically; otherwise, false.
The default value is false.
Overrides:
For text primitives, vertical stretching is typically disabled to maintain proper text positioning and prevent text from being improperly aligned within the available vertical space.
Gets or sets the text content displayed by this primitive.
public string Text { get; set; }
A string containing the text to display. Returns an empty string if the value is null.
Implements:
The text property supports various formatting features including mnemonics (ampersand characters), HTML rendering capabilities, and automatic layout adjustments based on the available space.
Setting this property automatically triggers layout invalidation and may enable HTML rendering if the text contains HTML markup and HTML rendering is not explicitly disabled.
Gets or sets the text alignment within the primitive's bounds.
public ContentAlignment TextAlignment { get; set; }
A ContentAlignment value that specifies how text is aligned within the available space. The default value is MiddleLeft.
Implements:
This property controls both horizontal and vertical text alignment. Common values include TopLeft, MiddleCenter, and BottomRight among others, providing flexible text positioning within the primitive's layout bounds.
Gets or sets the text orientation for rendering.
public Orientation TextOrientation { get; set; }
An Orientation value that specifies whether text is rendered horizontally or vertically. The default value is Horizontal.
Implements:
When set to Vertical, the text is rotated 90 degrees counterclockwise. This property is useful for creating vertical labels, headers, or other UI elements that require rotated text display.
Gets or sets the text rendering hint that controls the quality and appearance of text rendering.
public virtual TextRenderingHint TextRenderingHint { get; set; }
A TextRenderingHint value that specifies the text rendering quality. The default value is SystemDefault.
This property determines the quality of text rendering, affecting anti-aliasing, hinting, and overall text appearance. Use AntiAlias for smooth text rendering or ClearTypeGridFit for optimal LCD display quality.
Gets or sets a value indicating whether the text should wrapped to the available layout rectangle.
public bool TextWrap { get; set; }
true if the text should wrapped to the available layout rectangle otherwise, false.
Implements:
Gets or sets a value indicating whether the control interprets an ampersand character (&) in the control's Text property to be an access key prefix character.
public bool UseMnemonic { get; set; }
true if the label doesn't display the ampersand character and underlines the character after the ampersand in its displayed text and treats the underlined character as an access key; otherwise, false if the ampersand character is displayed in the text of the control. The default is true.
Implements:
Methods
Performs the core arrangement logic for the element within the specified final rectangle.
protected override void ArrangeCore(RectangleF finalRect)
The final rectangular area allocated for this element.
Overrides:
Arranges the RadElement to its final location. The element must call the Arrange method of each of its children.
protected override SizeF ArrangeOverride(SizeF finalSize)
The size that is available for element.
Returns:The rectangle occupied by the element. Usually finalSize. Should you return different size, the Layout system will restart measuring and rearranging the items. That could lead to infinite recursion.
Overrides:
In this method call to the Arrange method of each child must be made.
Gets the IFilter instance that may be used to filter the properties, treated as Stylable for this element.
public SizeF GetTextSize(SizeF proposedSize, TextParams textParams)
Implements:
public SizeF GetTextSize(TextParams textParams)
Implements:
Initializes member fields to their default values. This method is called prior the CreateChildItems one and allows for initialization of members on which child elements depend.
protected override void InitializeFields()
Overrides:
public SizeF MeasureOverride(SizeF availableSize, TextParams textParams)
Implements:
Measures the space required by the RadElement
Used by the layout system.
protected override SizeF MeasureOverride(SizeF availableSize)
The size that is available to the RadElement. The available size can be infinity (to take the full size of the element)
Returns:The minimum size required by the element to be completely visible. Cannot be infinity.
Overrides:
In this method call to the Measure method of each child must be made.
public void OnMouseMove(object sender, MouseEventArgs e)
Implements:
Called when a property value has changed, allowing for custom response to property changes.
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
The property changed event arguments.
Overrides:
public void PaintPrimitive(IGraphics graphics, float angle, SizeF scale, TextParams textParams)
Implements:
public void PaintPrimitive(IGraphics graphics, TextParams textParams)
Implements:
Returns the text as a string.