所以我的问题是,我在 WPF 中有一个带有 ContentPresenter 的按钮,该按钮具有文本块的资源:
<ContentPresenter Name="contentHolder" Width="55.77" Height="10.979" RenderTransformOrigin="0.5,0.5" Canvas.Left="3.646" Canvas.Top="9.608"
Margin="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
RecognizesAccessKey="True">
<ContentPresenter.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontFamily" Value="Arial"/>
<Setter Property="FontSize" Value="10.667"/>
<Setter Property="Foreground" Value="#FF141006"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</ContentPresenter.Resources>
</ContentPresenter>
我有一个故事板,它正在改变按钮的背景颜色,它的内容是什么时候(正常/鼠标悬停/按下/禁用)。一切都很好....期望按钮的内容在按下时不会改变文本颜色。我的 ColorAnimationUsingKeyFrames 看起来像这样:
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="contentHolder" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
<SplineColorKeyFrame KeyTime="00:00:00" Value="White"/>
</ColorAnimationUsingKeyFrames>
如前所述,我的所有触发器以及无法正常工作的触发器,唯一的问题是内容演示器中 textBlock 的文本没有改变……有人对此事有任何见解吗?