2009-10-11 110 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