Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9215053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:06:55+00:00 2026-06-18T02:06:55+00:00

I have a WrapPanel with 3 buttons. <WrapPanel Orientation=Horizontal> <Button Content=Book1 /> <Button Content=Book2

  • 0

I have a WrapPanel with 3 buttons.

<WrapPanel Orientation="Horizontal">
   <Button Content="Book1" />
   <Button Content="Book2" />
   <Button Content="Book3" />
</WrapPanel>

If i click on Book1 i see the content for Book1. If i click on Book2 i see the content for Book2 etc. Is there any command that can strikethrough the button if i click on it? In Html there is “del” for text:

<del>Strikethrough</del>

I want same but in wpf and with Buttons

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:06:56+00:00Added an answer on June 18, 2026 at 2:06 am

    Add TextDecoration object to TextBlock.TextDecorations collection in click event (for example):

    XAML:

    <Button Click="Button_Click_1">
       <TextBlock>
           Book 1
       </TextBlock>
    </Button>
    

    And handler:

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
       // ... your logic
    
       var button = (Button)sender;
       var textBlock = (TextBlock)button.Content;
    
       // if decoration wasn't already inserted
       //
       if (!textBlock.TextDecorations.Any())
           textBlock.TextDecorations.Add(new TextDecoration { Location = TextDecorationLocation.Strikethrough });
     }
    

    UPDATE: answer for your comment – the simplest way

    XAML

    <Button x:Name="button1" Click="Button_Click_1">
                <TextBlock>
                    Book 1
                </TextBlock>
            </Button>
    
            <Button x:Name="button2" Click="Button_Click_2">
                <TextBlock>
                    Book 2
                </TextBlock>
            </Button>
    

    Code:

    private void SetStrikethrough(Button b, Boolean strikethrough)
            {
                var textBlock = (TextBlock)b.Content;
    
                if (strikethrough)
                {
                    if (!textBlock.TextDecorations.Any())
                        textBlock.TextDecorations.Add(
                            new TextDecoration { Location = TextDecorationLocation.Strikethrough });
                }
                else
                {
                    textBlock.TextDecorations.Clear();
                }
            }
    
            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                var button = (Button)sender;
                SetStrikethrough(button1, true);
                SetStrikethrough(button2, false);
            }
    
            private void Button_Click_2(object sender, RoutedEventArgs e)
            {
                var button = (Button)sender;
                SetStrikethrough(button2, true);
                SetStrikethrough(button1, false);
            }
    

    Note that this code is always assumes that a button content is a textblock. Just for simplicity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xaml code: <Grid> <WrapPanel> <TextBox ></TextBox> <Button Content=GetIt /> </WrapPanel> </Grid>
I have a WrapPanel that has a button as a child element. Both the
I have a ListView with Horizontal WrapPanel as its ItemsPanelTemplate. I want to get
Is there a virtualizing WrapPanel available? Commercial or free ones. I have seen some
I´m facing this problem: I have a Button that works like a WrapPanel using
I have a ListBox with ItemsPanelTemplate of WrapPanel. There's some left & right padding
I have some items in a WrapPanel. I want to be able to click
I have couple buttons which im putting in wrapPanel in loop: for (int i
I have dynamically created WrapPanel (_wp) with several Borders. And I need create handler
I have this case <WrapPanel> <CheckBox>Really long name</CheckBox> <CheckBox>Short</CheckBox> <CheckBox>Longer again</CheckBox> <CheckBox>Foo</CheckBox> <Slider MinWidth=200

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.