ToggleButton
The ToggleButton
control is a subclass of the Button
control that has a built-in checked
state. This means the button can be checked or unchecked on click by a user. You may change the styling of controls based on whether ToggleButton
is checked or not by using the :checked
pseudoclass.
Source code
Examples
Speaker Mute Button
This button will show a muted speaker icon or an un-muted speaker icon based on whether the button is checked or unchecked, which the ToggleButton
control toggles between when users click on the button.
<Style Selector="ToggleButton DrawingPresenter.tbchecked">
<Setter Property="IsVisible" Value="False"/>
</Style>
<Style Selector="ToggleButton:checked DrawingPresenter.tbchecked">
<Setter Property="IsVisible" Value="True"/>
</Style>
<Style Selector="ToggleButton DrawingPresenter.tbunchecked">
<Setter Property="IsVisible" Value="True"/>
</Style>
<Style Selector="ToggleButton:checked DrawingPresenter.tbunchecked">
<Setter Property="IsVisible" Value="False"/>
</Style>