在动画完成后,KeyFrameAnimation不允许我手动覆盖动画值

时间:2013-04-01 17:30:43

标签: wpf animation

我有一个带有KeyFrameAnimation FadeIn效果的窗口

<Storyboard x:Key="FadeIn">
    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="window" Storyboard.TargetProperty="(UIElement.Opacity)">
        <EasingDoubleKeyFrame KeyTime="0" Value="0" />
        <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0.8" />
    </DoubleAnimationUsingKeyFrames>
</Storyboard>

<Window.Triggers>
    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
        <BeginStoryboard x:Name="BusyAnimation_BeginStoryboard" Storyboard="{StaticResource FadeIn}" />
    </EventTrigger>
</Window.Triggers>

在Code Behind中我正在处理MouseEnter和MouseLeave:

    private void FancyNotificationView_OnMouseEnter(object sender, MouseEventArgs e)
    {
        SetValue(Window.OpacityProperty, 1.0);
        Debug.WriteLine((double) GetValue(Window.OpacityProperty));
    }

    private void FancyNotificationView_OnMouseLeave(object sender, MouseEventArgs e)
    {
        SetValue(Window.OpacityProperty, 0.8);
    }

只要触发器处于活动状态,这将无效。不知何故,动画阻碍了我手动设置这些属性。如何保持动画并让MouseEnter和MouseLeave按照我的意图行事?

0 个答案:

没有答案