【问题标题】:Color of button read only error按钮颜色只读错误
【发布时间】:2012-06-18 13:02:31
【问题描述】:

我对 WPF 的操作有点困惑。我可以更改按钮的文本但不能更改颜色,它给出了只读属性错误。似乎设计有问题。文本更改颜色会引发错误。

svrSmtp.Stop()

btnStartServer.Background.ClearValue(Button.BackgroundProperty)
btnStartServer.Content = "Start Proxy"

【问题讨论】:

  • 可以将按钮的背景颜色设置为 Null,它只是绘制一个普通的按钮。
  • 或者尝试使用新的 SolidColorBrush 设置它,其值为 #00...... 将点作为颜色的 HEX 代码,但这并不重要,因为 00 表示Alpha 值为 0
  • 是的,将其设置为红色有效,谢谢。我想是试图做错,再次感谢。

标签: wpf button colors


【解决方案1】:

您想清除 Button 上 Button.Background 的值,而不是它的背景属性。

btnStartServer.ClearValue (Button.BackgroundProperty);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-29
    • 2021-04-03
    • 1970-01-01
    • 2016-11-09
    • 2021-08-18
    • 1970-01-01
    • 2019-12-13
    • 1970-01-01
    相关资源
    最近更新 更多