【发布时间】:2017-04-09 12:12:35
【问题描述】:
我在 ResourceDictionary 文件中有以下样式
<Color x:Key="LightCyan">LightCyan</Color>
<SolidColorBrush x:Key="LightCyanBrush" Color="{StaticResource LightCyan}" />
<Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="Width" Value="150" />
<Setter Property="Margin" Value="0,0,0,3" />
</Style>
<Style TargetType="TextBox" BasedOn="{StaticResource TextBoxStyle}">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="False">
<!-- Change brush color at run time -->
<Setter Property="Background" Value="{StaticResource LightCyanBrush}" />
</Trigger>
</Style.Triggers>
</Style>
我需要在运行时从颜色十六进制代码更改 IsReadOnly = False 时的 TextBox 背景颜色。
【问题讨论】:
标签: c# wpf resourcedictionary