WPF Why the assigned background cannot override setter value in style triggers? <p>I have a <code>Style</code> for a <code>TextBox</code> like this:</p> <pre><code>&lt;Style x:Key="TextBox_Standard" TargetType="{x:Type TextBoxBase}" &gt; &lt;Setter Property="Control.FontFamily" Value="/#Calibri" /&gt; &lt;Setter Property="Control.FontSize" Value="12" /&gt; &lt;Setter Property="Control.Margin" Value="2" /&gt; &lt;Setter Property="Control.Height" Value="21" /&gt; &lt;Setter Property="Control.VerticalAlignment" Value="Center" /&gt; &lt;Setter Property="SnapsToDevicePixels" Value="True"/&gt; &lt;Setter Property="UndoLimit" Value="0"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type TextBoxBase}"&gt; &lt;Border Name="Border" CornerRadius="1" Padding="1" Background="{StaticResource WindowBackgroundBrush}" BorderBrush="{StaticResource SolidBorderBrush}" BorderThickness="1" &gt; &lt;ScrollViewer Margin="0" x:Name="PART_ContentHost" /&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsEnabled" Value="False"&gt; &lt;Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}"/&gt; &lt;Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/&gt; &lt;Setter Property="Cursor" Value="Arrow"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsReadOnly" Value="True"&gt; &lt;Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}"/&gt; &lt;Setter Property="Focusable" Value="False"/&gt; &lt;Setter Property="Cursor" Value="Arrow"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>It was made to make sure the foreground color to be black and background color to be gray when it's not editable.</p> <p>but apparently now there's a requirement to change the background programmatically when it's not editable, so I tried it like this:</p> <p><code>txtBox.Background = Brushes.Yellow;</code></p> <p>but what happens is it still have a white background when editable and gray background when not editable.</p> <p>Where did I go wrong?</p>