0

我创建了一个故事板来为一个图像控件设置动画,该图像控件以编程方式放置在我的画布上。故事板是在 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>

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

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

非常感谢您提前。

4

1 回答 1

0

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

这包括它的容器和边距。

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

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

于 2012-08-03T20:08:33.210 回答