我有一个触发器,可以在单击按钮时触发OptionsShow故事板动画。这没有问题。当我单击我创建的选项按钮时,我将网格淡入其中,类似于自定义工具提示。当用户离开该网格时,我使用OptionsHide故事板动画淡出。如果我离开网格并在网格完全消失之前快速悬停在网格上,网格会不断闪烁。
似乎不断闪烁是因为初始隐藏动画无法完成,但我似乎无法弄清楚如何调试它。我没有" OnEnter"网格触发器重新显示网格,因此我不确定它何时显示不透明度100%的网格,开始淡化并不断重复此过程。
如果有人对此有任何经验,任何帮助或信息都会很棒。
<Window.Resources>
<Storyboard x:Key="OptionsShow">
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="Border">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Border">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="OptionsHide">
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="Border">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
<DiscreteObjectKeyFrame KeyTime="0:0:0.2" Value="{x:Static Visibility.Collapsed}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Border">
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<!--This is my button in my menu bar. On click I show my tooltip grid.-->
<EventTrigger RoutedEvent="ButtonBase.Click" SourceName="button">
<BeginStoryboard Storyboard="{StaticResource OptionsShow}"/>
</EventTrigger>
<!--When I leave the tooltip grid, make the tooltip grid fade out.-->
<EventTrigger RoutedEvent="UIElement.MouseLeave" SourceName="Border">
<BeginStoryboard x:Name="OptionsHide_BeginStoryboard" Storyboard="{StaticResource OptionsHide}"/>
</EventTrigger>
</Window.Triggers>