1

私のアニメーションを考えるとscene1C# code後ろを使用して「スキップ」という名前のボタンを使用して一時停止し、後で別のアニメーションを再生するにはどうすればよいですかscene2

<Window.Resources>
    <Storyboard x:Key="scene1">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="whitebox">
            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1.7" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" Storyboard.TargetName="charName">
            <DiscreteStringKeyFrame KeyTime="0:0:2" Value="Teacher"/>
            <DiscreteStringKeyFrame KeyTime="0:0:7.8" Value="Teacher"/>
            <DiscreteStringKeyFrame KeyTime="0:0:8" Value="Teacher"/>
        </StringAnimationUsingKeyFrames>
        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.HorizontalAlignment)" Storyboard.TargetName="charName">
            <DiscreteObjectKeyFrame KeyTime="0:0:2" Value="{x:Static HorizontalAlignment.Left}"/>
            <DiscreteObjectKeyFrame KeyTime="0:0:7.8" Value="{x:Static HorizontalAlignment.Left}"/>
            <DiscreteObjectKeyFrame KeyTime="0:0:8" Value="{x:Static HorizontalAlignment.Left}"/>
        </ObjectAnimationUsingKeyFrames>
        <ObjectAnimationUsingKeyFrames
        (too long… etc.)
4

2 に答える 2

2

コードビハインドでは、this.Resources["scene1"]を使用してストーリーボードオブジェクトを取得します。

Storyboard storyBoard = this.Resources["scene1"] as Storyboard;
storyBoard.Begin();

ストーリーボードの「完了」イベントを使用して、ストーリーボードが完了したときに別のアニメーションを開始します

storyBoard.Completed += eventHandler

電話

storyBoard.Stop()

アニメーションを停止します。

于 2012-06-27T06:09:38.017 に答える
1

Jeric Paul Calderon の回答に加えて、一時停止機能もありますstoryBoard.Pause()
。主なことはPause()、現在の再生位置でアニメーションを一時停止し、Stop()停止して開始点に戻ることです。

于 2012-06-27T08:42:26.920 に答える