我为一个控件定义了一些VisualStates
我创建了淡入淡化(" ThankYouOverlay")并带有一条消息:
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition To="ThankYou" GeneratedDuration="0:0:0.3">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Opacity)" To="1" />
</Storyboard>
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Collapsed}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Opacity)" To="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="ThankYou">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
此转换正常,但我无法更改动画持续时间。我使用VisualTransition
GeneratedDuration
属性和各个动画的不同组合进行了游戏。 Duration
属性,但无论这些更改如何,动画的实际持续时间都会持续1秒(默认情况下,我假设)。
我错过了什么?如何更改转换的持续时间?
答案 0 :(得分:0)
为了尝试向同事证明这一点,我在每个可用的Duration
属性上指定了Duration
...然后它按照我预期的方式工作:
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition To="ThankYou" GeneratedDuration="0:0:0.3">
<Storyboard Duration="0:0:0.3">
<ObjectAnimationUsingKeyFrames Duration="0:0:0.3" Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Duration="0:0:0.3" Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Opacity)" To="1" />
</Storyboard>
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal">
<Storyboard Duration="0:0:0.3">
<ObjectAnimationUsingKeyFrames Duration="0:0:0.3" Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Collapsed}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Duration="0:0:0.3" Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Opacity)" To="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="ThankYou">
<Storyboard Duration="0:0:0.3">
<ObjectAnimationUsingKeyFrames Duration="0:0:0.3" Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Duration="0:0:0.3" Storyboard.TargetName="ThankYouOverlay" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
我不确定哪些是必要的,哪些是多余的。