我在WPF按钮中应用了动画。点击按钮,屏幕打开。
每当用户将鼠标移到按钮上时,按钮会弹回,然后再坐下来。它工作正常,但如果用户点击按钮然后按钮试图打开屏幕,动画冻结,按钮似乎挂在空中一段时间。当屏幕打开然后它自行安定下来。
我希望动画不会受到与之关联的操作的干扰。
StoryBoard的代码是
<Storyboard x:Key="StoryboardClient" AutoReverse="True" RepeatBehavior="1x">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="image">
<EasingDoubleKeyFrame KeyTime="0" Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<BounceEase EasingMode="EaseIn" Bounces="0" Bounciness="0"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-32">
<EasingDoubleKeyFrame.EasingFunction>
<BounceEase EasingMode="EaseIn" Bounces="0" Bounciness="0"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="image">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
按钮的XAML是
<Button Style="{StaticResource ButtonMainScreen}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<Command:EventToCommand Command="{Binding OpenCommand}" CommandParameter="Client"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter">
<ei:ControlStoryboardAction Storyboard="{StaticResource StoryboardClient}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<StackPanel Style="{StaticResource StackPanelTitleButtons}">
<Image Style="{StaticResource ImageMainUI}" x:Name="image" Source="Images/Client.png" />
<TextBlock Text="Clients" Style="{StaticResource TextBlockMainScreen}" />
</StackPanel>
</Button>