WPF ToggleButton strikethrough text when IsClicked

deleyd
deleyd used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial