How do I change foreground color of a button when clicked?

user2962761

I have something like this:

                        <Grid>
                            <StackPanel Margin="100,0,98,0">
                                <Button x:Name="BtProd"
                                   Content="{Binding Produto}"     
                                   FontSize="{StaticResource PhoneFontSizeLarge}"
                                   Foreground="{Binding Color}"
                                   Click="BtProd_Click">
                                </Button>
                            </StackPanel>
                        </Grid>

How do I change the text color of a button in the C# .cs file?

   private void BtProd_Click(object sender, RoutedEventArgs e)
    {
    ?
    }

I'd like to change from white to lightgray when user clicks the button. Thank You.

xmashallax
(sender as Button).Foreground = new SolidColorBrush(Colors.LightGray);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I change the Foreground color of a label in a custom button when the button is enabled or disabled?

From Dev

How can I change the background color of a button when clicked?

From Dev

How can I change the color of a button with CSS only when it is clicked?

From Dev

How do I change the text of a button when it is clicked? - Swift

From Dev

Change button color when clicked

From Dev

How do I change a button's color when pressed and reset to original color when a different button are pressed?

From Dev

How to change color of a button when clicked using bootstrap?

From Dev

How to change the color of button and pause screen for few second when it clicked?

From Dev

Android: Change button color when clicked

From Dev

Change tab color when button clicked

From Dev

Change button color when clicked - Bootstrap

From Dev

Change focus color when button clicked

From Dev

Change color of circle button when clicked in WPF

From Dev

How can I change the background color of elements when they're clicked?

From Dev

How can I change the background color of elements when they're clicked?

From Dev

How can I make a span change color when a link is clicked

From Dev

How to change the foreground color of ttk.Button when its state is active?

From Dev

Button Foreground color change on Pressed

From Java

How can I change the colour of a button when clicked at runtime?

From Dev

How to change listview's button background color when button clicked in android

From Dev

How do I run function in vala asynchronously when a button is clicked

From Java

How do I open phone settings when a button is clicked?

From Dev

c# How do I open the combobox when the button is clicked

From Dev

How do I run function in vala asynchronously when a button is clicked

From Dev

How do I render a component when a button is clicked in React Native

From Dev

How do I change the image on a JButton when clicked?

From Dev

How to change title color of UIButton when clicked?

From Dev

How do I make a button in a custom NSView change color on mouseover?

From Dev

How do I change the color of text from a radio button?

Related Related

  1. 1

    How do I change the Foreground color of a label in a custom button when the button is enabled or disabled?

  2. 2

    How can I change the background color of a button when clicked?

  3. 3

    How can I change the color of a button with CSS only when it is clicked?

  4. 4

    How do I change the text of a button when it is clicked? - Swift

  5. 5

    Change button color when clicked

  6. 6

    How do I change a button's color when pressed and reset to original color when a different button are pressed?

  7. 7

    How to change color of a button when clicked using bootstrap?

  8. 8

    How to change the color of button and pause screen for few second when it clicked?

  9. 9

    Android: Change button color when clicked

  10. 10

    Change tab color when button clicked

  11. 11

    Change button color when clicked - Bootstrap

  12. 12

    Change focus color when button clicked

  13. 13

    Change color of circle button when clicked in WPF

  14. 14

    How can I change the background color of elements when they're clicked?

  15. 15

    How can I change the background color of elements when they're clicked?

  16. 16

    How can I make a span change color when a link is clicked

  17. 17

    How to change the foreground color of ttk.Button when its state is active?

  18. 18

    Button Foreground color change on Pressed

  19. 19

    How can I change the colour of a button when clicked at runtime?

  20. 20

    How to change listview's button background color when button clicked in android

  21. 21

    How do I run function in vala asynchronously when a button is clicked

  22. 22

    How do I open phone settings when a button is clicked?

  23. 23

    c# How do I open the combobox when the button is clicked

  24. 24

    How do I run function in vala asynchronously when a button is clicked

  25. 25

    How do I render a component when a button is clicked in React Native

  26. 26

    How do I change the image on a JButton when clicked?

  27. 27

    How to change title color of UIButton when clicked?

  28. 28

    How do I make a button in a custom NSView change color on mouseover?

  29. 29

    How do I change the color of text from a radio button?

HotTag

Archive