带有 DiscreteObjectKeyFrame 的情节提要在 Windows Phone 8 中不起作用 [英] Storyboard with DiscreteObjectKeyFrame is not working in windows phone 8

查看:42
本文介绍了带有 DiscreteObjectKeyFrame 的情节提要在 Windows Phone 8 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Windows Phone 8 应用程序中有一个故事板动画,就像这样.

I have a storyboard animation in my windows phone 8 app like this one.

<Storyboard x:Name="eqAnimation" RepeatBehavior="forever">
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="imageEq" Storyboard.TargetProperty="Source">
            <DiscreteObjectKeyFrame KeyTime="0:0:0.0" Value="/Assets/zikzak.png" />
            <DiscreteObjectKeyFrame KeyTime="0:0:0.2" Value="/Assets/zikzak2.png" />
        </ObjectAnimationUsingKeyFrames>
</Storyboard>

但它根本没有播放.我必须更改图像控件的源才能制作连续动画.

but it's not playing at all. I have to change the source of an image control to make a sequential animation.

推荐答案

我有一个工作片段,刚刚用 Windows Phone 8 模拟器测试过.您可以将其复制到您的代码中(当然要更新图像路径),以查看它是否正在运行.

I have a working snippet, just tested with Windows Phone 8 emulator. You can copy it to your code (update the image paths, of course), to see if it is running.

故事板在页面加载时开始,而不是在代码隐藏中开始.

The Storyboard begins when the page is loaded, not started in code-behind.

<Image x:Name="img"> <!--do not set the Source here-->
    <Image.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard>
                <Storyboard RepeatBehavior="Forever">
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="img"
                                           Storyboard.TargetProperty="Source">
                        <DiscreteObjectKeyFrame KeyTime="0:0:0.01" Value="/Assets/zikzak.png"/>
                        <DiscreteObjectKeyFrame KeyTime="0:0:0.2" Value="/Assets/zikzak2.png"/>
                        <DiscreteObjectKeyFrame KeyTime="0:0:0.4" Value="/Assets/zikzak.png"/>
                        <DiscreteObjectKeyFrame KeyTime="0:0:0.6" Value="/Assets/zikzak2.png"/>

                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Image.Triggers>
</Image>

这篇关于带有 DiscreteObjectKeyFrame 的情节提要在 Windows Phone 8 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆