Checkbox
The Checkbox widget provides a boolean input option with a visual checkbox and optional label.
Overview
Section titled “Overview”Checkbox displays a checkable box with a label. It supports keyboard activation and provides visual feedback for checked and focus states.
Properties
Section titled “Properties”IsChecked (bool)
Section titled “IsChecked (bool)”Whether the checkbox is checked.
checkbox.IsChecked = true;Label (string)
Section titled “Label (string)”The checkbox label text.
checkbox.Label = "Enable feature";BracketColor (Color)
Section titled “BracketColor (Color)”Color of the checkbox brackets (default: Yellow).
checkbox.BracketColor = Color.Yellow;CheckmarkColor (Color)
Section titled “CheckmarkColor (Color)”Color of the checkmark when checked (default: Green).
checkbox.CheckmarkColor = Color.Green;Events
Section titled “Events”CheckedChanged
Section titled “CheckedChanged”Raised when the checked state changes.
checkbox.CheckedChanged += (isChecked) =>{ Console.WriteLine($"Checked: {isChecked}");};Methods
Section titled “Methods”Toggle()
Section titled “Toggle()”Toggles the checkbox state.
checkbox.Toggle();Keyboard Interaction
Section titled “Keyboard Interaction”- Space or Enter: Toggle checked state
- Tab: Navigate to next focusable widget
Usage Example
Section titled “Usage Example”var checkbox = new Checkbox("Enable notifications"){ X = 10, Y = 5, Width = 30, Height = 1, ForegroundColor = Color.White, IsChecked = false};
checkbox.CheckedChanged += (isChecked) =>{ Console.WriteLine($"Notifications: {(isChecked ? "ON" : "OFF")}");};Related Widgets
Section titled “Related Widgets”- Button - For action buttons
- ListBox - For multiple selections
- Base Widget - Base class documentation