CheckBox
Toggle control with [x] / [ ] indicator and content label.
Overview
CheckBox extends ButtonBase and provides a toggleable boolean control
rendered as [x] Content when checked or [ ] Content when unchecked.
It supports focus and hover visual states, command binding, and fires Checked,
Unchecked, and Click events. Each click toggles the
IsChecked property between true and false.
Basic Example
<StackPanel Orientation="Vertical">
<CheckBox Content="Enable notifications" />
<CheckBox Content="Dark mode" IsChecked="True" />
<CheckBox Content="Auto-save" />
</StackPanel>
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| IsChecked | bool | false | Whether the checkbox is currently checked. |
| FocusColor | Color | Cyan | Border/indicator color when the control has focus. |
| HoverColor | Color | Yellow | Border/indicator color when the mouse hovers over the control. |
| Content | object | null | The label displayed next to the check indicator. Inherited from ContentControl. |
| Command | ICommand | null | Command executed when the checkbox is toggled. Inherited from ButtonBase. |
| CommandParameter | object | null | Parameter passed to the Command. Inherited from ButtonBase. |
| Padding | Thickness | 0 | Inner padding around the content. Inherited from Control. |
Examples
Basic Toggle
<CheckBox Content="I agree to the terms" />
Data-Bound CheckBox
<CheckBox Content="Remember me"
IsChecked="{Binding RememberMe, Mode=TwoWay}" />
Disabled CheckBox
<CheckBox Content="Premium feature"
IsEnabled="False"
IsChecked="True" />
CheckBox with Command
<CheckBox Content="Enable logging"
Command="{Binding ToggleLoggingCommand}"
FocusColor="Green"
HoverColor="LightGreen" />
Keyboard Shortcuts
| Key | Action |
|---|---|
| Enter | Toggle the checked state and fire Click event. |
| Space | Toggle the checked state and fire Click event. |
| Tab | Move focus to the next focusable control. |
| Shift+Tab | Move focus to the previous focusable control. |
Key Concepts
CheckBoxextendsButtonBase, inheriting Click event and Command support.- The visual indicator renders as
[x]when checked and[ ]when unchecked. - Toggling fires
CheckedorUncheckedevents depending on the new state, plus theClickevent on every toggle. - Use
IsChecked="{Binding ...}"withMode=TwoWayfor two-way data binding. - When
IsEnabledisFalse, the control cannot be toggled and renders in a dimmed state. - Focus and hover colors can be customized via
FocusColorandHoverColorproperties.