我希望当我点击按钮时,能够改变其背景颜色,使其从红色变为绿色,再变为红色等等。但是,当我点击按钮时,背景颜色并没有改变。以下是我尝试过的方法:
第三种解决方案似乎最相关,但并不起作用。
button4.Background.SetValue(BackgroundProperty,new SolidColorBrush(Colors.Red)); -> catastrophic error
button4.SetValue(BackgroundProperty,new SolidColorBrush(Colors.Red)); -> nothing
button4.Background = new SolidColorBrush(Colors.Red); -> nothing
第三种解决方案似乎最相关,但并不起作用。