【问题标题】:Difficulty in getting DoubleAnimationUsingKeyFrames to work难以让 DoubleAnimationUsingKeyFrames 工作
【发布时间】:2015-01-15 17:37:00
【问题描述】:

我正在尝试将此情节提要 xaml 标记转换为 vb 代码。但是,当我运行代码时,没有任何反应,没有引发异常或错误。我有什么遗漏吗?

从 xaml 运行时情节提要按预期工作,但是在我的代码隐藏翻译过程中出现了问题。

最后我可以验证附加到情节提要的目标元素确实存在。

XMAL

 <Storyboard x:Name="FlipAnimation">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="Front">
            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="Back">
            <EasingDoubleKeyFrame KeyTime="0" Value="-90"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="-90"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>

代码隐藏

 Dim firstKf As DoubleAnimationUsingKeyFrames = New DoubleAnimationUsingKeyFrames
    firstKf.KeyFrames.Add(New EasingDoubleKeyFrame With {.KeyTime = TimeSpan.Zero, .Value = "0"})
    firstKf.KeyFrames.Add(New EasingDoubleKeyFrame With {.KeyTime = TimeSpan.FromMilliseconds(200), .Value = "90"})
    Media.Animation.Storyboard.SetTargetProperty(firstKf, New PropertyPath(PlaneProjection.RotationYProperty))
    Media.Animation.Storyboard.SetTarget(firstKf, front)

    Dim secondKf As DoubleAnimationUsingKeyFrames = New DoubleAnimationUsingKeyFrames
    secondKf.KeyFrames.Add(New EasingDoubleKeyFrame With {.KeyTime = TimeSpan.Zero, .Value = "-90"})
    secondKf.KeyFrames.Add(New EasingDoubleKeyFrame With {.KeyTime = TimeSpan.FromMilliseconds(200), .Value = "-90"})
    secondKf.KeyFrames.Add(New EasingDoubleKeyFrame With {.KeyTime = TimeSpan.FromMilliseconds(400), .Value = "0"})
    Media.Animation.Storyboard.SetTargetProperty(secondKf, New PropertyPath(PlaneProjection.RotationYProperty))
    Media.Animation.Storyboard.SetTarget(secondKf, back)

    Dim sb = New Media.Animation.Storyboard
    sb.Children.Add(firstKf)
    sb.Children.Add(secondKf)
    sb.Begin()

【问题讨论】:

  • 尝试将duration设置为firstKf

标签: vb.net xaml windows-phone-8 windows-phone-8.1


【解决方案1】:

看起来您在两个动画上绑定了不正确的属性路径。你想要的

New PropertyPath("Projection.RotationY")

或许

New PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)")

因为frontback 不直接包含PlaneProjection.RotationYProperty

【讨论】:

    猜你喜欢
    • 2012-01-11
    • 2013-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-28
    • 2016-02-19
    • 2013-04-28
    相关资源
    最近更新 更多