Table of Contents

Class TextBlock

Namespace
Icy.UI.Controls
Assembly
IcyUI.dll

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

string

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

float

FontStyle

Gets or sets the font style (bold/italic/etc.) to render Text with.

public FontStyle FontStyle { get; set; }

Property Value

FontStyle

Text

Gets or sets the text to display.

public string Text { get; set; }

Property Value

string

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

Size

Size recommended to display the UIElement.

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

context IRenderContext

The context to render with.