我怎样才能在.cs代码文件中制作这种动画?

时间:2012-03-03 16:16:17

标签: windows-phone-7 windows-mobile windows-phone-7.1

    <Storyboard x:Name="Storyboard1" Completed="Storyboard1_Completed">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="imageBack1">
            <EasingDoubleKeyFrame KeyTime="0:0:0.25" Value="90"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="imageBack1">
            <DiscreteObjectKeyFrame KeyTime="0:0:0.25">
                <DiscreteObjectKeyFrame.Value>
                    <Visibility>Visible</Visibility>
                </DiscreteObjectKeyFrame.Value>
            </DiscreteObjectKeyFrame>
        </ObjectAnimationUsingKeyFrames>
        <DoubleAnimation Duration="0:0:0.25" To="90" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="image1" d:IsOptimized="True"/>
    </Storyboard> 

我正在做这样的事情

    private Timeline CreateFlipAnimation(TimeSpan beginTime, UIElement target, UIElement target2) 
    {
        DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames(){
            BeginTime = beginTime
        };

        //target.Projection = new PlaneProjection();
        Storyboard.SetTargetProperty(animation, new PropertyPath(UIElement.ProjectionProperty));
        Storyboard.SetTarget(animation, target);
        animation.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = kt1, Value = 90 });
        animation.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = kt2, Value = 0 });

        ObjectAnimationUsingKeyFrames animation1 = new ObjectAnimationUsingKeyFrames()
        {
            BeginTime = beginTime
        };
        Storyboard.SetTargetProperty(animation1, new PropertyPath(UIElement.VisibilityProperty));
        Storyboard.SetTarget(animation1, target);
        animation1.KeyFrames.Add(new DiscreteObjectKeyFrame() { KeyTime = kt1, Value = Visibility.Visible });

        DoubleAnimation animation2 = new DoubleAnimation()
        {
            //Duration = , 
            To = 90
        };
        //target2.Projection = new PlaneProjection();
        Storyboard.SetTargetProperty(animation2, new PropertyPath(UIElement.ProjectionProperty));
        Storyboard.SetTarget(animation2, target2);


    }

现在我不知道如何把它放在.cs文件中

        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="imageBack1">

我已评论该部分,请告诉我如何继续这个...? 在持续时间我应该如何初始化价值......

1 个答案:

答案 0 :(得分:0)

好消息:你几乎已经做对了!

这个Ruby脚本会像你要做的那样做很多动画:http://script.iron7.com/#/Script/Detail?scriptId=81baa9940368436c8244ab7810331b65&userLowerCaseName=iron7

视频 - http://www.youtube.com/watch?v=5k8SG82e1Rc

代码基本上相当于:

target2.Projection = new PlaneProjection();
Storyboard.SetTargetProperty(animation2, new PropertyPath(PlaneProjection.RotationZProperty));
Storyboard.SetTarget(animation2, target2.Projection);

要设置持续时间,您可以使用DoubleAnimation中的持续时间或DoubleAnimationUsingKeyFrames中的KeyFrame KeyTimes来设置持续时间