Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF动画暂停/继续_Wpf_Animation - Fatal编程技术网

WPF动画暂停/继续

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:

我正在尝试WPF动画,我有点卡住了。以下是我需要做的:

鼠标悬停:

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

鼠标输出:

暂停2秒钟

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


我有淡入淡出效果,但我不知道如何实现暂停,甚至不知道是否可行。

以下是一些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
属性