TextBox
Editable text input with caret, selection, and placeholder support.
Overview
The TextBox control extends Control and provides a full-featured
editable text input. It supports single-line mode (default) and multi-line mode when
AcceptsReturn is true. Features include caret navigation,
text selection (Shift+Arrow), clipboard operations (Ctrl+C/V/X), word-level navigation
(Ctrl+Arrow), and placeholder text.
ViewModel (C#)
public class TextInputViewModel : ViewModelBase
{
public string InputText
{
get;
set
{
if (SetProperty(ref field, value))
{
StatusText = $"Characters: {value?.Length ?? 0}";
OutputText = $"Echo: {value}";
}
}
} = "";
public string StatusText { get; set => SetProperty(ref field, value); }
public string OutputText { get; set => SetProperty(ref field, value); }
public string NotesText { get; set => SetProperty(ref field, value); }
}
Key Concepts
- Single-line (default) vs multi-line (
AcceptsReturn="True") PlaceholderTextwatermark shown when empty and unfocused- Selection: Shift+Arrow, Shift+Home/End, Ctrl+A
- Clipboard: Ctrl+C (copy), Ctrl+V (paste), Ctrl+X (cut)
- Word navigation: Ctrl+Left/Right, Ctrl+Backspace
IsReadOnlyprevents editing while allowing selection and copyMaxLengthconstrains input length (0 = unlimited)TextChangedevent for reactive updates- Focus visual states:
FocusColor/HoverColorborder - Cursor rendered with
TextDecorations.Inverse(terminal-native)