【问题标题】:Storyboard WP7 - CoordinatesStoryboard WP7 - 坐标
【发布时间】:2012-08-03 20:00:11
【问题描述】:

我创建了一个情节提要来为一个图像控件设置动画,该图像控件以编程方式放置在我的画布上。故事板是在 Expression Blend 中创建的。

当我播放 Storyboard 时,图像消失并在其他地方出现动画(我最终看到图像控件在最后飞了进来)。它不会动画我首先放置图像的位置。故事板有效,但它没有在我想要动画的地方制作动画。 控件应该在屏幕底部和特定图像的右侧进行动画处理。这就是我通过代码更改图像位置的原因。

这里是xml:

 <Storyboard x:Name="sbBagExit">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.SkewX)" Storyboard.TargetName="imgBag">
            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="11"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="10.9973"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="imgBag">
            <EasingDoubleKeyFrame KeyTime="0" Value="332"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="332"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="332"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="imgBag">
            <EasingDoubleKeyFrame KeyTime="0" Value="-16"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="169.983"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
    <Storyboard x:Name="sbBagDrop">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="imgBag">
            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="imgBag">
            <EasingDoubleKeyFrame KeyTime="0" Value="-172"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="332.001"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="344"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="332"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="imgBag">
            <EasingDoubleKeyFrame KeyTime="0" Value="-8"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="-8"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="-8"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="imgBag">
            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0.829"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="imgBag">
            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1.2"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>

第二个故事板发生在第一个故事板之后。

我已经为此苦苦思索了整整两个星期……谁能看到我看不到的东西?

非常感谢您。

【问题讨论】:

    标签: windows-phone-7 storyboard expression-blend


    【解决方案1】:

    因为您使用 Blend 来生成动画,Blend 的 From 和 To 属性值基于您在 Blend 中使用的元素的坐标和布局。

    这包括它的容器和边距。

    因为您没有指定所需的坐标,所以我无法告诉您出了什么问题。

    我会首先更改 TranslateX 和 TranslateY,以了解它们的功能以及它们何时执行我希望他们执行的操作。

    【讨论】:

    • 如何在 Expression Blend 中创建它,以免出现此错误?
    • 使容器和元素与您应用它的元素完全一样。我更喜欢仅使用相对坐标,因此设置动画的 By 属性或仅 To 属性(不指定 From 属性)。这样可以防止那些奇怪的 300 个数字。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-02
    • 2014-11-22
    • 2011-02-18
    • 1970-01-01
    • 2022-01-16
    相关资源
    最近更新 更多