WPF ToggleButton strikethrough text when IsClicked

In WPF XAML I want to make a ToggleButton which when pressed adds a strikethrough to the text.

I've seen:
Changing the Text on a ToggleButton When a User Clicks On It
https://wpf.2000things.com/tag/togglebutton/

Problem is Strikethrough needs to be applied to the underlying TextBlock, not the Togglebutton.
deleydAsked:
Who is Participating?
 
Chris StanyonConnect With a Mentor Commented:
Take a look at this:

<ToggleButton>
    <ToggleButton.Style>
        <Style TargetType="{x:Type ToggleButton}">
            <Setter Property="Content" Value="Disarmed" />
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter Property="Content">
                        <Setter.Value>
                            <TextBlock Text="Armed" TextDecorations="Strikethrough" />
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
    </ToggleButton.Style>
</ToggleButton>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.