Click here to Skip to main content
15,790,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i was just wondering if there would be a way to change the Image background of a button using cs and then keep it the same when disabled as when it is enabled and when switching between the two states, Thanks.

What I have tried:

bt1.Background = "/Assets/Image1.png";
bt1.IsEnabled = false;
Updated 19-Apr-20 6:34am

1 solution

By doing this, you would violate Windows user interface guidelines, and confuse users.

If you want to "turn off" the behavior you have defined for a Control, here's an example:
btnRender.Click -= btnRender_Click;
This removes a specific EventHandler from a Control. See: [^], [^]

But, isn't it really a good idea to have some visual indication that a Control is not active ?
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900