Class TextBlock
Displays a single run of text using a font resolved from Configuration's Fonts service.
[ContentProperty("Text")]
public class TextBlock : UIElement, INotifyPropertyChanging, IBindingTarget, INotifyPropertyChanged, INotifyFocusChanged
- Inheritance
-
TextBlock
- Implements
- Inherited Members
- Extension Methods
Remarks
A thin wrapper over Icy.Rendering.Fonts - no wrapping/multi-run styling/text alignment; those are left for a future control if actually needed. Renders nothing (and measures as empty) until Text is set and a font resolves; FontFamily is optional, since resolution falls back to DefaultFontFamily and then FallbackFont.
Properties
FontFamily
Gets or sets the font family to render Text with.
public string FontFamily { get; set; }
Property Value
Remarks
Resolved via GetOrLoad(FontInfo) - the family must already be importable/loaded by the configured FontSystem (e.g. via ImportFont<TContext>(TContext, string) or EnableSystemFonts()) for text to actually render.
FontSize
Gets or sets the font size, in pixels.
public float FontSize { get; set; }
Property Value
FontStyle
Gets or sets the font style (bold/italic/etc.) to render Text with.
public FontStyle FontStyle { get; set; }
Property Value
Text
Gets or sets the text to display.
public string Text { get; set; }
Property Value
Methods
ArrangeContent()
Handles custom arrange logic when overridden in any UIElement instance.
protected override void ArrangeContent()
Remarks
This method is called during the arrange pass to position and size the element's content within its final bounds. The element's position and size are already determined by the layout system and available in the ActualBounds property.
When implementing this method:
- Position child elements within the available space;
- Respect the element's padding when positioning content;
- Handle any content-specific layout requirements;
- Call Arrange() on child elements if needed.
MeasureContent()
Handles custom measure logic when overridden in any UIElement instance.
protected override Size MeasureContent()
Returns
Remarks
This method is called during the measure pass to determine the desired size of the element. The returned size should represent the natural size of the element's content, without considering any constraints, margins, or padding.
When implementing this method:
- Return the natural size needed to display the content;
- Do not include padding, margins, or borders in the returned size;
- Consider the content's actual dimensions (e.g., text length, image size);
- Return Empty if the element has no content.
OnRender(IRenderContext)
Handles custom render logic when overridden in any UIElement instance.
protected override void OnRender(IRenderContext context)
Parameters
contextIRenderContextThe context to render with.