在可视状态动画不动画(WinRT的) [英] Animations in visual state do not animate (WinRT)

查看:158
本文介绍了在可视状态动画不动画(WinRT的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发的Windows 8.1 RTM。我有一个double类型的自定义的依赖项属性的自定义控件。这个控制已被放置在用户的控制。我呼吁用户控件VisualStateManager.GoToState(对照,真)。该动画应2秒过渡。然而,它只是卡从0到1和从1到0的回调函数只调用0或1。如果我直接设置依赖属性为0和1之间的任意值,它按预期工作。

I am developing on Windows 8.1 RTM. I have a custom control with a custom dependency property of type double. This control has been placed in a user control. I am calling VisualStateManager.GoToState(control, true) on the user control. The animation should transition for 2 seconds. However, it simply snaps from 0 to 1 and from 1 to 0. The callback function is only called with either 0 or 1. If I directly set the dependency property to any value between 0 and 1, it works as expected.

我有以下XAML:

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:controls="using:MyControls" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="TestStates">
            <VisualStateGroup.Transitions>
              <VisualTransition GeneratedDuration="0:0:2"/>
            </VisualStateGroup.Transitions>
            <VisualState x:Name="A">
                <Storyboard>
                    <DoubleAnimation
                        EnableDependentAnimation="True"
                        Duration="0"
                        Storyboard.TargetName="MyControl1"
                        Storyboard.TargetProperty="MyDependencyProperty"
                        To="0"/>
                </Storyboard>
            </VisualState>
            <VisualState x:Name="B">
                <Storyboard>
                    <DoubleAnimation
                        EnableDependentAnimation="True"
                        Duration="0"
                        Storyboard.TargetName="MyControl1"
                        Storyboard.TargetProperty="MyDependencyProperty"
                        To="1"/>
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <controls:MyControl x:Name="MyControl1" MyDependencyProperty="0">
</Grid>
</UserControl>

如果我设定的目标属性不透明,它的工作原理。

If I set the target property to Opacity, it works.

综观previous问题,EnableDependentAnimation似乎是这种行为的常见原因,但我已经将它设置为true。

Looking at previous questions, EnableDependentAnimation seems to be the common culprit for this behavior, but I've already set it to true.

Timeline.AllowDependentAnimations是真实的。

Timeline.AllowDependentAnimations is true.

我已经剥离了控制下降到只有一个依赖属性在回调没有逻辑。同样的问题。

I've stripped the control down to just the one dependency property with no logic in the callback. Same issue.

推荐答案

请参阅我正在经历的依赖属性在动画,发现了一个intereting点,我想我应该分享

See i was going through the animation on dependency property and found an intereting point I thought I should share

要被动画化,动画的目标属性必须是依赖属性。此外,被动画化,目标属性的值类型必须由现有的一个<支持href=\"http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.animation.timeline.aspx\"相对=nofollow>时间轴中衍生的动画类型。当施加并运行一个动画,该动画值以较高的precedence比任何值进行操作(如本地值)该属性否则有。动画也有一个可选HoldEnd行为可以导致动画应用到特性值即使动画可视方式显示被停止。

To be animated, the animation's target property must be a dependency property. Also, to be animated, the target property's value type must be supported by one of the existing Timeline-derived animation types. When an animation is applied and running, the animated value operates at a higher precedence than any value (such as a local value) that the property otherwise has. Animations also have an optional HoldEnd behavior that can cause animations to apply to property values even if the animation visually appears to be stopped.

我不知道,可能是这将帮助这里的链接的文档

I dont know may be This will help Here's the link to the documentation

动画

这篇关于在可视状态动画不动画(WinRT的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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