Edit

Share via


ToggleButton control

The ToggleButton control represents a button that can be toggled between two or three states. It's a base class for controls like CheckBox and RadioButton, providing the fundamental toggle functionality. You can set the IsThreeState property to true to enable an indeterminate state in addition to checked and unchecked states.

Styles and templates

You can modify the default ControlTemplate to give the control a unique appearance. For more information, see Create a template for a control.

Content property

The ToggleButton defines the Content property as its content property. This means you can set any object, such as text or UI elements, as the button's content.

Parts

The ToggleButton control doesn't define any named parts.

Visual states

The following table lists the visual states for the ToggleButton control.

VisualState Name VisualStateGroup Name Description
Normal CommonStates The control is in its normal state.
MouseOver CommonStates The mouse is over the control.
Pressed CommonStates The control is pressed.
Disabled CommonStates The control is disabled.
Focused FocusStates The control has keyboard focus.
Unfocused FocusStates The control doesn't have keyboard focus.
Checked CheckStates The control is checked.
Unchecked CheckStates The control is unchecked.
Indeterminate CheckStates The control is in an indeterminate state (when IsThreeState is true).
Valid ValidationStates The control is valid and has no validation errors.
InvalidFocused ValidationStates The control has a validation error and has keyboard focus.
InvalidUnfocused ValidationStates The control has a validation error but doesn't have keyboard focus.

Note

If the Indeterminate visual state doesn't exist in your control template, the Unchecked visual state is used as the default visual state.

See also