我正在使用 WPF。请查看代码中与前景相关的注释。当文本框获得焦点时,字体应更改为白色,但它不起作用。为什么?
<ControlTemplate TargetType="{x:Type TextBox}">
<Border x:Name="bg" BorderBrush="#FFDCDCC9" Background="#FFDCDCC9" BorderThickness="1">
<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" TargetName="bg" Value="#FFEC94C0"/>
<Setter Property="Background" TargetName="bg" Value="#FFEC94C0"/>
<Setter Property="BorderThickness" TargetName="bg" Value="2"/>
<Setter Property="Cursor" Value="Hand"/>
</Trigger>
<Trigger Property="IsFocused" Value="True" >
<Setter Property="BorderBrush" TargetName="bg" Value="#FFB5266E"/>
<Setter Property="Background" TargetName="bg" Value="#FFEC94C0"/>
<!-- foreground is invalid -->
<Setter Property="Foreground" TargetName="bg" Value="white"/>
<Setter Property="BorderThickness" TargetName="bg" Value="2"/>
<Setter Property="Cursor" Value="Hand"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>