Skip to content

Text markup reference

TextBlock, Run, MarkupTextBlock, and Label.

Receiver: Run.

Method Sets Summary
Background(Color? value) Background Sets the highlight color painted behind the run; null paints nothing.
BaselineOffset(double value) BaselineOffset Sets the baseline shift in DIPs; positive raises the run above the line’s baseline.
Bold() FontWeight = Bold Renders the run bold.
Decoration(TextDecoration value) Decoration Sets underline and strikethrough for the run.
FontFamily(string value) FontFamily Sets the font family; null inherits from the owning text element.
FontSize(double? value) FontSize Sets the font size in points; null inherits from the owning text element.
FontWeight(FontWeight? value) FontWeight Sets the font weight; null inherits from the owning text element.
Foreground(Color? value) Foreground Sets the text color; null inherits from the owning text element.
Italic(bool value = true) Italic Sets whether the run renders italic.
Strikethrough() Adds a strikethrough, keeping any other decoration.
Text(string value) Text Sets the run text.
Underline() Adds an underline, keeping any other decoration.

Receiver: Label and derived types (where T : Label).

Method Sets Summary
AccessKeyTarget(UIElement target) Sets Target, the element that receives the access key activation.
BindText(ObservableValue<TSource> source, Func<TSource, string> convert) bind Text Binds the text to a converted observable value.
BindText(ObservableValue<string> source) bind Text Binds the text to an observable value.
Target(UIElement value) Target Sets the element that receives OnAccessKey when this label’s access key is activated; null lets the access key bubble up the parent chain.
Text(string value) Text Sets the text; an underscore prefix marks the access key character (e.g. “_Name” registers Alt+N) and a double underscore is a literal underscore.
TextAlignment(TextAlignment value) TextAlignment Sets the horizontal text alignment.
TextTrimming(TextTrimming value) TextTrimming Sets the text trimming mode.
TextWrapping(TextWrapping value) TextWrapping Sets the text wrapping mode.
VerticalTextAlignment(TextAlignment value) VerticalTextAlignment Sets the vertical text alignment.

Receiver: MarkupTextBlock.

Method Sets Summary
Markup(string value) Markup Sets the source markup.
Options(TextMarkupOptions options) Options Sets markup presentation options.

Receiver: TextBlock and derived types (where T : TextBlock).

Method Sets Summary
BindText(ObservableValue<TSource> source, Func<TSource, string> convert) bind Text Binds the text to a converted observable value.
BindText(ObservableValue<string> source) bind Text Binds the text to an observable value.
Bold() FontWeight = Bold Sets the font weight to bold.
FontSize(ThemeFontSize size) FontSize Sets the font size resolved once from the current theme’s ThemeMetrics; themes with per-variant metrics re-resolve by calling this inside a WithTheme callback.
Inlines(params Run[] runs) Inlines Replaces the block’s inline runs.
Italic(bool italic = true) Sets the font style to italic, or back to upright.
SemiBold() FontWeight = SemiBold Sets the font weight to semi-bold.
Text(string value) Text Sets the text content; setting it replaces Inlines, and while runs are present the value is their concatenated text.