我正在 Windows 8.1 RTM 上开发。我有一个自定义控件,其自定义依赖属性为 double 类型。此控件已放置在用户控件中。我在用户控件上调用 VisualStateManager.GoToState(control, true)。动画应该过渡 2 秒。但是,它只是从 0 到 1 和从 1 到 0 捕捉。回调函数只使用 0 或 1 调用。如果我直接将依赖属性设置为 0 到 1 之间的任何值,它会按预期工作。
我有以下 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>
如果我将目标属性设置为不透明度,它会起作用。
查看之前的问题,EnableDependentAnimation 似乎是这种行为的常见罪魁祸首,但我已经将其设置为 true。
Timeline.AllowDependentAnimations 为真。
我已经将控件剥离到只有一个依赖属性,回调中没有逻辑。同样的问题。