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 7617651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:12:11+00:00 2026-05-31T03:12:11+00:00

This is connected with my previous question as it’s dealt with the same piece

  • 0

This is connected with my previous question as it’s dealt with the same piece of code; now that I’ve accomplished the changing of the background of the button, the problem is that now i need to implement the same code but not not for ButtonPressed but for clicked button. I’ve added click handlers in the code but it’s not working – the background is not changing. I tried different approaches, even with using bitmaps and imagesources, but it’s not working, the change simply does not happen. Now I want to implement the change of the background image but it needs to be done in the XAML file, not in the .cs . Again the code:

<Button x:Class="proba4.UserControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="120" d:DesignWidth="300" IsEnabled="True">
    <Button.Template>
        <ControlTemplate TargetType="{x:Type Button}">
            <Grid>
                <Image Name="Normal" Source="C:\stuff\off_button.gif"/>
                <Image Name="Pressed" Source="C:\stuff\on_button.gif" Visibility="Hidden"/>

            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsPressed" Value="True">
                    <Setter TargetName="Normal" Property="Visibility" Value="Hidden"/>
                    <Setter TargetName="Pressed" Property="Visibility" Value="Visible"/>
                </Trigger>

            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Button.Template>
</Button>

Note that I’ve already looked for some button properties for clicking, but there was none, and all the implementations I’ve found on internet are dealing with adding Button_Click method in the .cs code of the control, and since that is not working for me, I need to find another way – hopefully something like fully implemented click control using WPF.
I guess this is delicate, but I will greatly appreciate any help with this, thanks.

  • 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-05-31T03:12:12+00:00Added an answer on May 31, 2026 at 3:12 am

    It sounds like you want the behavior of a ToggleButton, not a Button. On Button clicking is a discrete event rather than a state that the control goes into that can be expressed by a property. A ToggleButton switches back and forth between two (or three) states when clicked, and the IsChecked property represents the state and can be bound in a Trigger like you’re doing with IsPressed in your example.

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

Sidebar

Related Questions

This is a more concrete question that is connected with my previous one. I
This question is connected to my other question but I changed the logic a
Suppose, I have a connected socket after writing this code.. if ((sd = accept(socket_d,
I'm gleaning from this question [ Facebook Connect Won't Validate that using Facebook Connect
I have few questions connected with struct and typedef, there is piece of code
This is a continuation of my previous question which I posted when I wasn't
This question is in continuation to my previous post located here . Since there
Apologies, but I have searched and read previous answers on this question but couldn't
This leads on from my previous question here . I have been developing with
This question is an extension of a previous question: Return an object in VBA

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.