有没有办法为 VisualState 转换设置延迟?
我希望我的控件在延迟一段时间后启动视觉状态转换动画。 我尝试在视觉状态故事板上设置 BeginTime。但它什么也没提供:( 有什么办法可以做到这一点吗?
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded" SourceObject="{Binding ElementName=controlRoot}">
<ei:GoToStateAction StateName="MouseOverData"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter" SourceObject="{Binding ElementName=textBlockChart}">
<ei:GoToStateAction StateName="MouseOverCharts"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave" SourceObject="{Binding ElementName=textBlockChart}">
<ei:GoToStateAction StateName="Normal"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter" SourceObject="{Binding ElementName=grid}">
<ei:GoToStateAction StateName="MouseOverCharts"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave" SourceObject="{Binding ElementName=grid}">
<ei:GoToStateAction StateName="Normal"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter" SourceObject="{Binding ElementName=textBlockData}">
<ei:GoToStateAction StateName="MouseOverData"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave" SourceObject="{Binding ElementName=textBlockData}">
<ei:GoToStateAction StateName="Normal"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter" SourceObject="{Binding ElementName=grid1}">
<ei:GoToStateAction StateName="MouseOverData"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave" SourceObject="{Binding ElementName=grid1}">
<ei:GoToStateAction StateName="Normal"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.2" />
<VisualTransition From="MouseOverCharts" GeneratedDuration="0:0:0.2" To="Normal">
<VisualTransition.GeneratedEasingFunction>
<CircleEase EasingMode="EaseIn"/>
</VisualTransition.GeneratedEasingFunction>
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="MouseOverCharts">
<Storyboard>
<ColorAnimation Duration="0" To="#FFEFE78A" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)" Storyboard.TargetName="textBlockChart" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="10" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)" Storyboard.TargetName="textBlockChart" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)" Storyboard.TargetName="textBlockChart" d:IsOptimized="True"/>
<ColorAnimation Duration="0" To="#FFEFE78A" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBlockChartContent" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="220" Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
<VisualState x:Name="MouseOverData">
<Storyboard BeginTime="0:0:10">
<ColorAnimation BeginTime="0:0:5" Duration="0" To="#FFEFE78A" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBlockDataContent" d:IsOptimized="True"/>
<ColorAnimation BeginTime="0:0:5" Duration="0" To="#FFEFE78A" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)" Storyboard.TargetName="textBlockData" d:IsOptimized="True"/>
<DoubleAnimation BeginTime="0:0:5" Duration="0" To="10" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)" Storyboard.TargetName="textBlockData" d:IsOptimized="True"/>
<DoubleAnimation BeginTime="0:0:5" Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)" Storyboard.TargetName="textBlockData" d:IsOptimized="True"/>
<DoubleAnimation BeginTime="0:0:5" Duration="0" To="220" Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="grid1" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
谢谢。
I'd like for my control to start visual state transition animation after some delay.
I tried setting BeginTime on a visual state Storyboard. But it gave nothing :(
Is there any way to do this?
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded" SourceObject="{Binding ElementName=controlRoot}">
<ei:GoToStateAction StateName="MouseOverData"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter" SourceObject="{Binding ElementName=textBlockChart}">
<ei:GoToStateAction StateName="MouseOverCharts"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave" SourceObject="{Binding ElementName=textBlockChart}">
<ei:GoToStateAction StateName="Normal"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter" SourceObject="{Binding ElementName=grid}">
<ei:GoToStateAction StateName="MouseOverCharts"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave" SourceObject="{Binding ElementName=grid}">
<ei:GoToStateAction StateName="Normal"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter" SourceObject="{Binding ElementName=textBlockData}">
<ei:GoToStateAction StateName="MouseOverData"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave" SourceObject="{Binding ElementName=textBlockData}">
<ei:GoToStateAction StateName="Normal"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter" SourceObject="{Binding ElementName=grid1}">
<ei:GoToStateAction StateName="MouseOverData"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave" SourceObject="{Binding ElementName=grid1}">
<ei:GoToStateAction StateName="Normal"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.2" />
<VisualTransition From="MouseOverCharts" GeneratedDuration="0:0:0.2" To="Normal">
<VisualTransition.GeneratedEasingFunction>
<CircleEase EasingMode="EaseIn"/>
</VisualTransition.GeneratedEasingFunction>
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="MouseOverCharts">
<Storyboard>
<ColorAnimation Duration="0" To="#FFEFE78A" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)" Storyboard.TargetName="textBlockChart" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="10" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)" Storyboard.TargetName="textBlockChart" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)" Storyboard.TargetName="textBlockChart" d:IsOptimized="True"/>
<ColorAnimation Duration="0" To="#FFEFE78A" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBlockChartContent" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="220" Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
<VisualState x:Name="MouseOverData">
<Storyboard BeginTime="0:0:10">
<ColorAnimation BeginTime="0:0:5" Duration="0" To="#FFEFE78A" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBlockDataContent" d:IsOptimized="True"/>
<ColorAnimation BeginTime="0:0:5" Duration="0" To="#FFEFE78A" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)" Storyboard.TargetName="textBlockData" d:IsOptimized="True"/>
<DoubleAnimation BeginTime="0:0:5" Duration="0" To="10" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)" Storyboard.TargetName="textBlockData" d:IsOptimized="True"/>
<DoubleAnimation BeginTime="0:0:5" Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)" Storyboard.TargetName="textBlockData" d:IsOptimized="True"/>
<DoubleAnimation BeginTime="0:0:5" Duration="0" To="220" Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="grid1" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 Storyboard 上的 BeginTime 属性。
示例:
MSDN
You can use BeginTime property on the Storyboard.
Example:
MSDN
尝试删除
内的GeneratedDuration="0:0:0.2"
Try removing
GeneratedDuration="0:0:0.2"
inside<VisualTransition GeneratedDuration="0:0:0.2" />