WPF动画暂停/继续

Jus*_*inT 3 wpf animation

我正在尝试WPF动画,我有点卡住了.这是我需要做的事情:

鼠标移到:

淡入(2秒内0%至100%不透明度)

鼠标移开:

暂停2秒钟

淡出(2秒内100%到0%的不透明度)

我有Fade In和Fade Out效果,但我无法弄清楚如何实现Pause,或者即使它是可能的.

Dre*_*kes 5

这里有一些XAML,展示了如何做你想做的事情(你可以把整个东西粘贴到Kaxaml中试试看:

<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>
Run Code Online (Sandbox Code Playgroud)

诀窍是使用BeginTime了的propertly DoubleAnimation类.