Skip to content

Latest commit

 

History

History
65 lines (45 loc) · 2.75 KB

File metadata and controls

65 lines (45 loc) · 2.75 KB
-api-id -api-type
T:Microsoft.UI.Xaml.Controls.Primitives.ToggleButton
winrt class

Microsoft.UI.Xaml.Controls.Primitives.ToggleButton

-description

Represents a control that a user can select (check) or clear (uncheck). Base class for controls that can switch states, such as CheckBox and RadioButton.

-xaml-syntax

<ToggleButton .../>
-or-
<ToggleButton>
    singleObject
</ToggleButton>
-or-
<ToggleButton>contentString</ToggleButton>

-remarks

ToggleButton can have three states:

State Property Value
checked IsChecked true
unchecked IsChecked false
indeterminate IsChecked null

For the ToggleButton to report the indeterminate state, you must set the IsThreeState property to true.

Note

ToggleButton has the same visual state for the indeterminate and unchecked states. Derived controls, like CheckBox, may define different visual states for each state.

ToggleButton derived classes

ToggleButton is the parent class for several immediately derived controls that toggle and are selectable:

-examples

Tip

For more info, design guidance, and code examples, see Toggle switches.

[!div class="nextstepaction"] Open the WinUI 3 Gallery app and see the ToggleButton in action

The WinUI 3 Gallery app includes interactive examples of most WinUI 3 controls, features, and functionality. Get the app from the Microsoft Store or get the source code on GitHub.

The following example shows how to create a three-state ToggleButton control.

[!code-xaml1]

-see-also

ButtonBase, AppBarToggleButton, CheckBox, RadioButton