如何在wpf中单击按钮时更改按钮背景颜色 [英] How to change button back ground color on button click in wpf

查看:1585
本文介绍了如何在wpf中单击按钮时更改按钮背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我是WPF的新手。我正在使用MVVM模式。

现在我想在按钮点击时更改按钮组颜色。

任何人都可以告诉我该怎么办?



Hello,

I am new in WPF. I am using MVVM pattern.
Now i want to change the button back group color on button click.
Can any one please tell me how can i do it?

private Brush _brushobj;
        public Brush BrushObj
        {
            get
            {
                return _brushobj;
            }
            set
            {

                _brushobj = value;
                OnPropertyChanged("BrushObj");
            }
        }









i设置了这样的属性。现在使用按钮绑定此属性,例如



背景={Binding brushobj}



i have set the property like this. Now and bind this property with button like

Background="{Binding brushobj}"






还需要什么其他东西?

i必须通过按钮点击功能调用它吗?

怎么能我叫它?



what other things are required?
i have to call it from button click function?
how can i call it?

推荐答案

看到这个.. :)



点击和悬停时WMF背景发生变化 [ ^ ]



WPF背景coloe教程 [ ^ ]
see this.. :)

WPF background changes when click and hover[^]

WPF Background coloe tutorial[^]


使用行为在使用MVVM时对事件执行任何操作。

了解行为



http://wpftutorial.net/Behaviors.html [ ^ ]



问候,

Karuppasamy
Use behaviors to do any actions on event, when using MVVM.
Go through about Behaviors

http://wpftutorial.net/Behaviors.html[^]

Regards,
Karuppasamy


这篇关于如何在wpf中单击按钮时更改按钮背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆