Class Label
Represents a text label control.
[DefaultBindingProperty("Text")]
[ControlCategory("Common")]
public class Label : Control, IBaseObject, IDisposableObject, ISupportInitialize, IFocusable, ITextProperty, IComponent, IControl, IDisposable, IWin32Window, INotifyDataErrorInfo
- Inheritance
-
Label
- Implements
Examples
Here is how to declare a Label in UIXML:
<Border>
<Label Name="label" Text="Sample Label" Margin="8" TextChanged="Label_TextChanged"/>
</Border>
And the corresponding event handler in the code-behind:
private void Label_TextChanged(object? sender, EventArgs e)
{
var text = label.Text == "" ? "\"\"" : label.Text;
MessageBox.Show(text, string.Empty);
}
Also, a Label can be created from code:
var Label = new Alternet.UI.Label();
Remarks
Label controls are typically used to provide descriptive text for a control. For example, you can use a Label to add descriptive text for a TextBox control to inform the user about the type of data expected in the control. Label controls can also be used to add descriptive text to a Window to provide the user with helpful information. For example, you can add a Label to the top of a Window that provides instructions to the user on how to input data in the controls on the form. Label controls can also be used to display run time information on the status of an application. For example, you can add a Label control to a form to display the status of each file as a list of files is processed.
Examples of how a Label can look on different platforms:
Set Text property to specify the text displayed on the control.
A Label, like any other Control, can be disabled by
setting its Enabled property to false
.
Constructors
- Label(string?)
Initializes a new instance of the Label class with specified text.
Properties
- ControlKind
Returns control identifier.
- MaxTextWidth
Gets or sets maximal width of text in the control.
Methods
- CoerceTextForHandler(string)
Called to modify text before it is assigned to the handler.
- CreateHandler()
Creates a handler for the control.
- OnHandlerTextChanged()
Called when handler's text property is changed.
- Wrap(double?)
Wraps Text so that each of its lines becomes at most width dips wide if possible (the lines are broken at words boundaries so it might not be the case if words are too long).