WPF动画暂停/继续
我正在尝试WPF动画,我有点卡住了。以下是我需要做的: 鼠标悬停: 淡入(2秒内不透明度为0%到100%) 鼠标输出: 暂停2秒钟 淡出(2秒内不透明度为100%到0%)WPF动画暂停/继续,wpf,animation,Wpf,Animation,我正在尝试WPF动画,我有点卡住了。以下是我需要做的: 鼠标悬停: 淡入(2秒内不透明度为0%到100%) 鼠标输出: 暂停2秒钟 淡出(2秒内不透明度为100%到0%) 我有淡入淡出效果,但我不知道如何实现暂停,甚至不知道是否可行。以下是一些XAML,展示了如何实现您的目标(您可以将整个内容粘贴到中进行尝试: <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http:
我有淡入淡出效果,但我不知道如何实现暂停,甚至不知道是否可行。以下是一些XAML,展示了如何实现您的目标(您可以将整个内容粘贴到中进行尝试:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Background="Red">
<Grid.Triggers>
<EventTrigger RoutedEvent="Grid.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<DoubleAnimation Storyboard.TargetProperty="Opacity"
From="1" To="0"
Duration="0:00:02"
BeginTime="0:00:02" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Grid.Triggers>
</Grid>
</Page>
诀窍是使用DoubleAnimation
类的BeginTime
属性