【发布时间】:2011-04-26 19:55:04
【问题描述】:
我有一个通过 ControlTemplate 定义的 TextBox。由于 ControlTemplate,当 IsEnabled 属性设置为 false 时,TextBox 不再自动变灰。
为了提供此功能,我在 ControlTemplate 中使用了以下触发器:
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{x:Static SystemColors.GrayTextBrush}" />
</Trigger>
这很好用。但是我还必须设置 BackgroundColor 但我没有在SystemColors 中找到相应的条目。哪个条目是禁用控件(文本框)背景的正确条目?除了 SystemColors 还有其他来源吗?
我不想使用固定值。例如设置Background="#f4f4f4",因为我担心在某些环境中,禁用背景有另一个值,然后我的控件看起来不应该甚至不可读(例如,如果 GrayTextBrush 的值接近 #f4)。
【问题讨论】: