2009-10-11 145 views
3

我正在试验WPF动画,而且我有点卡住了。这就是我需要做的:(在2秒内0%至100%的不透明度)WPF动画暂停/继续

淡入

鼠标移开:

鼠标悬停

暂停2秒

淡出(100%到2%不透明度在2秒)

我已经淡入和淡出效果,但我不知道如何实现暂停,或者即使它是可能的。

回答

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> 

诀窍是使用BeginTime propertly的DoubleAnimation

+0

非常感谢! – JustinT 2009-10-12 14:21:05