动画绑定KeyTime不起作用

时间:2015-10-01 12:14:54

标签: c# wpf animation data-binding

我目前正试图在TextBlock属性发生变化时淡入淡出Text。我有这个XAML:

<TextBlock DataContext="{Binding ElementName=main, Path=DataContext}"
           Height="18"
           Text="{Binding CurrentStatus, NotifyOnTargetUpdated=True}">
  <TextBlock.Triggers>
    <EventTrigger RoutedEvent="Binding.TargetUpdated">
      <BeginStoryboard>
        <Storyboard>
          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0:1" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="{Binding AnimationTime}" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0:1" Value="0"/>
          </DoubleAnimationUsingKeyFrames>
        </Storyboard>
      </BeginStoryboard>
    </EventTrigger>
  </TextBlock.Triggers>
</TextBlock>

除此之外,我要做的是:首先,花费1秒钟淡入,然后在Opacity期间保持AnimationTime 1,然后花1秒钟淡出。我用Snoop检查了AnimationTime的值,值很好。但是动画似乎忽略了限制值,淡出也不起作用。所以现在,它会像预期的那样消失,但随后就会消失。文本也仍在那里。有没有人发现该代码有什么问题?

编辑:AnimationTimeTimeSpan btw

0 个答案:

没有答案