Color legend plain property dependency property method
A light text element for captions, list rows and short descriptions. It lays its text out once, optionally wrapped, and draws it from the font atlas. It has no scrolling, editing or rich formatting; use a RichTextBox when you need those. ListBox.AddTextItem and the default items template make their rows from labels.
Label derives from BaseElement and has its members too. The text page shows it in context, with code and screenshots.
Names are colored by what they are: a plain property, a method, an event or a dependency property, which a style, a binding or an animation can set.
Properties
FontPath 🠆
string · The path of a TTF or OTF file to draw with (see Fonts). A path that loads replaces the font system in use; an empty or unreadable path goes back to the general font, but keeps a font system you set by hand.
FontSize 🠆
float · The font size in units. Negative values become 0, and 0 draws nothing. Default DefaultSettings.DefaultFontSize (14).
FontSystem 🠆
FontSystem · Read-only. The font system in use: FontSystemOverride, or GeneralFontSystem without one.
FontSystemOverride 🠆
FontSystem · A FontStashSharp font system for this label only, used instead of the general one. Setting FontPath sets it too. The label does not dispose it.
GeneralFontSystem 🠆
FontSystem · Static. The font system of every label and rich text box without one of their own; Label.GeneralFontSystem and RichTextBox.GeneralFontSystem are the same value. The bundled UbuntuMono unless you set one.
GeneralMouseCursorsSet 🠆
MouseCursorsSet · Static. The cursors of every element of this style type; null (the default) falls back to DefaultMouseCursorsSet.
GeneralStyle 🠆
LabelStyle · Static. The style of every element of this style type. It starts as a copy of the framework defaults; changing one of its properties updates every such element, a property it leaves unset takes its default.
LastFontError 🠆
Exception · Read-only. The exception of the last failed font preparation, null when the font is fine. The label draws nothing while it has no font.
LineCount 🠆
int · Read-only. The number of laid out lines, after wrapping.
LineSpacing 🠆
int · Extra space between two lines, in units. Negative values become 0.
MouseCursorsSet 🠆
MouseCursorsSet · Read-only. The cursors the element shows: its override, else the set given to the control it is a part of, else its type’s general set, else DefaultMouseCursorsSet.
MouseCursorsSetOverride 🠆
MouseCursorsSet · The cursors of this element only, passed on to its parts that have none of their own.
StyleOverride 🠆
LabelStyle · A style for this element only, applied over the general style. Setting it to null takes its values back out.
Text 🠆
string · The text shown. Line breaks start new lines, tabs become spaces. Default "".
TextAlignment 🠆
TextAlignment · How each line is placed across the width. Default Left.
TextMargin 🠆
Margin · The space between the label’s edges and its text, in units. It turns with TextRotation.
TextRotation 🠆
TextRotation · Turns the text and its frame by a quarter or a half turn. Default None.
VerticalTextAlignment 🠆
VerticalTextAlignment · Where the lines sit in a label taller than its text. Default Top.
WrapType 🠆
TextWrap · Whether lines break at spaces to fit the width. Applies only with a fixed or stretched width or a MaxWidth. Default NoWrap.
Methods
Label() 🠆
Label(string name = null) · Creates a label. The name is used by GetElementByName.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The element’s Name, which GetElementByName finds it by. Default: null. |
Draw() 🠆
Draw() · Draws the label’s background, then its lines straight from the font atlas. The framework calls it; you don’t need to.