为什么重复行为对我的故事板不起作用?

时间:2019-02-18 16:42:08

标签: c# wpf xaml

我希望我的情节提要一遍又一遍,所以我设置了Repeat Behavior =“ Forever” 但情节提要没有重新开始。

我尝试放置storyboard.completed,但调试器从未输入此事件 为什么情节提要没有结束,我没有将重复动作设置为大于1

我的故事板:

<Storyboard x:Key="napton" RepeatBehavior="Forever">
    <DoubleAnimationUsingPath Duration="0:0:3" Source="X" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="napton" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M351.5,142 L241,142"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <DoubleAnimationUsingPath Duration="0:0:3" Source="Y" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="napton" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M351.5,142 L241,142"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <DoubleAnimationUsingPath Duration="0:0:3" Source="Angle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="napton" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M351.5,142 L241,142"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="napton" RepeatBehavior="1x">
        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:3" Value="{x:Static Visibility.Hidden}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:12" Value="{x:Static Visibility.Hidden}"/>
    </ObjectAnimationUsingKeyFrames>
    <DoubleAnimationUsingPath BeginTime="0:0:3" Duration="0:0:2" Source="X" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="napton_back" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M526,134.5 L636.5,134.5"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <DoubleAnimationUsingPath BeginTime="0:0:3" Duration="0:0:2" Source="Y" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="napton_back" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M526,134.5 L636.5,134.5"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="napton_back" RepeatBehavior="1x">
        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:3" Value="{x:Static Visibility.Visible}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:5" Value="{x:Static Visibility.Hidden}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:12" Value="{x:Static Visibility.Hidden}"/>
    </ObjectAnimationUsingKeyFrames>
    <DoubleAnimationUsingPath BeginTime="0:0:5" Duration="0:0:7" Source="X" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="napton_orbit" RepeatBehavior="1x" Completed="Storyboard_
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M636,140.25 C636,237.31404 525.07855,316 388.25,316 C251.42145,316 140.5,237.31404 140.5,140.25 C140.5,43.185955 251.42145,-35.5 388.25,-35.5 C525.07855,-35.5 636,43.185955 636,140.25 z"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <DoubleAnimationUsingPath BeginTime="0:0:5" Duration="0:0:7" Source="Y" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="napton_orbit" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M636,140.25 C636,237.31404 525.07855,316 388.25,316 C251.42145,316 140.5,237.31404 140.5,140.25 C140.5,43.185955 251.42145,-35.5 388.25,-35.5 C525.07855,-35.5 636,43.185955 636,140.25 z"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="napton_orbit" RepeatBehavior="1x">
        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:5" Value="{x:Static Visibility.Visible}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:12" Value="{x:Static Visibility.Visible}"/>
    </ObjectAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="napton_orbit" RepeatBehavior="1x">
        <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
        <EasingDoubleKeyFrame KeyTime="0:0:5" Value="1"/>
        <EasingDoubleKeyFrame KeyTime="0:0:6.7" Value="1.5"/>
        <EasingDoubleKeyFrame KeyTime="0:0:8.5" Value="1"/>
        <EasingDoubleKeyFrame KeyTime="0:0:10.3" Value="0.5"/>
        <EasingDoubleKeyFrame KeyTime="0:0:12" Value="1"/>
    </DoubleAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="napton_orbit" RepeatBehavior="1x">
        <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
        <EasingDoubleKeyFrame KeyTime="0:0:5" Value="1"/>
        <EasingDoubleKeyFrame KeyTime="0:0:6.7" Value="1.5"/>
        <EasingDoubleKeyFrame KeyTime="0:0:8.5" Value="1"/>
        <EasingDoubleKeyFrame KeyTime="0:0:10.3" Value="0.5"/>
        <EasingDoubleKeyFrame KeyTime="0:0:12" Value="1"/>
    </DoubleAnimationUsingKeyFrames>
    <DoubleAnimationUsingPath BeginTime="0:0:5" Duration="0:0:2" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="sun" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M2,-0.25 L104,1.25"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <DoubleAnimationUsingPath BeginTime="0:0:5" Duration="0:0:2" Source="Y" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="sun" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M2,-0.25 L104,1.25"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="sun" RepeatBehavior="1x">
        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:5" Value="{x:Static Visibility.Visible}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:7" Value="{x:Static Visibility.Hidden}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:12">
            <DiscreteObjectKeyFrame.Value>
                <Visibility>Hidden</Visibility>
            </DiscreteObjectKeyFrame.Value>
        </DiscreteObjectKeyFrame>
    </ObjectAnimationUsingKeyFrames>
    <DoubleAnimationUsingPath BeginTime="0:0:7" Duration="0:0:2" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="sun_l" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M102.5,1.25 L-98.5,1.25"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <DoubleAnimationUsingPath BeginTime="0:0:7" Duration="0:0:2" Source="Y" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="sun_l" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M102.5,1.25 L-98.5,1.25"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="sun_l" RepeatBehavior="1x">
        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:7" Value="{x:Static Visibility.Visible}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:9" Value="{x:Static Visibility.Hidden}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:10">
            <DiscreteObjectKeyFrame.Value>
                <Visibility>Hidden</Visibility>
            </DiscreteObjectKeyFrame.Value>
        </DiscreteObjectKeyFrame>
        <DiscreteObjectKeyFrame KeyTime="0:0:12" Value="{x:Static Visibility.Hidden}"/>
    </ObjectAnimationUsingKeyFrames>
    <DoubleAnimationUsingPath BeginTime="0:0:9" Duration="0:0:3" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="sun_back" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M-100,-0.25 L3.5,-0.25"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <DoubleAnimationUsingPath BeginTime="0:0:9" Duration="0:0:3" Source="Y" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="sun_back" RepeatBehavior="1x">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M-100,-0.25 L3.5,-0.25"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="sun_back" RepeatBehavior="1x">
        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:9" Value="{x:Static Visibility.Visible}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:12">
            <DiscreteObjectKeyFrame.Value>
                <Visibility>Visible</Visibility>
            </DiscreteObjectKeyFrame.Value>
        </DiscreteObjectKeyFrame>
    </ObjectAnimationUsingKeyFrames>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(TileBrush.TileMode)" Storyboard.TargetName="napton" RepeatBehavior="1x">
        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static TileMode.None}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:0.6" Value="{x:Static TileMode.None}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:3" Value="{x:Static TileMode.None}"/>
    </ObjectAnimationUsingKeyFrames>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(TileBrush.Stretch)" Storyboard.TargetName="napton" RepeatBehavior="1x">
        <DiscreteObjectKeyFrame KeyTime="0:0:3" Value="{x:Static Stretch.Uniform}"/>
        <DiscreteObjectKeyFrame KeyTime="0:0:12" Value="{x:Static Stretch.UniformToFill}"/>
    </ObjectAnimationUsingKeyFrames>
    <DoubleAnimationUsingPath BeginTime="0:0:5" Duration="0:0:2" Source="Angle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="sun" RepeatBehavior="Forever">
        <DoubleAnimationUsingPath.PathGeometry>
            <PathGeometry Figures="M2,-0.25 L104,1.25"/>
        </DoubleAnimationUsingPath.PathGeometry>
    </DoubleAnimationUsingPath>
</Storyboard>

我想要获得的结果是使情节提要循环或知道情节提要为什么没有结束。

1 个答案:

答案 0 :(得分:0)

您遇到的问题是,最终的DoubleAnimationUsingPath动画的设置为RepeatBehavior="Forever",因此动画永远不会结束,因此Storyboard也不会结束。