如何动态更改WPF的背景颜色:s按钮 [英] How do I change dynamically a background color of a WPF:s button
问题描述
目标:
动态更改我自定义私有功能中按钮的背景颜色。起点是
Goal:
Change dynamically the button's background color inside of my customized private function. The start point is
gridMain.Children.
问题:
我尝试谷歌搜索,我读了关于类按钮和许多不同的网站,但我找不到相关的线索,以改变背景颜色。我的想法是,这个概念与nhibernate编辑数据然后保存它的能力相同。
我需要从
Problem:
I tried googling and I read about class button and lots of different website but I cannot find a relevant clue in order to change the background color. My way of thinking is that the concept will be same as nhibernate's ability to edit data and then save it.
I need to retrieve a specific button from
gridMain.Children.
有一个名字,btn_test,然后更改背景颜色然后保存。
再次,问题是我找不到相关代码来实现我的目的。
信息:
- 我正在使用VS 2013和WPF和C#。
- 在gridMain.Children里面。我有很多不同名称的按钮。动态创建按钮
that has a name, btn_test, and change the background color and then to be saved.
Again, the problem is that I cannot find a relevant code to my purpose.
Info:
- I'm using VS 2013 with WPF and C#.
- Inside of gridMain.Children. I have a lot of button with different name. Buttons are created dynamically
推荐答案
使用: FrameworkElement.Style属性 [ ^ ]
试试;)
访问: CP KB [ ^ ]
By using: FrameworkElement.Style Property[^]
Try ;)
Visit: CP KB[^]
这篇关于如何动态更改WPF的背景颜色:s按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!