有没有办法为 VisualState 转换设置延迟?

发布于 2024-12-11 09:16:04 字数 4886 浏览 0 评论 0原文

我希望我的控件在延迟一段时间后启动视觉状态转换动画。 我尝试在视觉状态故事板上设置 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

金兰素衣 2024-12-18 09:16:04

您可以使用 Storyboard 上的 BeginTime 属性。

示例:

<Storyboard BeginTime="0:0:2">

</Storyboard>

MSDN

You can use BeginTime property on the Storyboard.

Example:

<Storyboard BeginTime="0:0:2">

</Storyboard>

MSDN

白况 2024-12-18 09:16:04

尝试删除 内的 GeneratedDuration="0:0:0.2"

Try removing GeneratedDuration="0:0:0.2" inside <VisualTransition GeneratedDuration="0:0:0.2" />

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文