2010-09-09 27 views
2

是否可以爲LinearGradientBrush的StartPoint或EndPoint設置動畫效果?如果是這樣,Storyboard對象的動畫類型是什麼類型,因爲當我嘗試以下我得到「0,1」不是Double的有效值,我意識到我不應該使用DoubleAnimationUsingKeyFrames類型。是否可以在WPF中爲LinearGradientBrush創建動畫?

目前代碼:

<UserControl.Triggers> 
    <EventTrigger RoutedEvent="UserControl.Loaded"> 
     <BeginStoryboard> 
      <Storyboard> 
       <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" 
              Storyboard.TargetName="Path1" 
              Storyboard.TargetProperty="(Path.Stroke).(LinearGradientBrush.StartPoint)"> 
        <SplineDoubleKeyFrame KeyTime="00:00:0" Value="0,1"/> 
        <SplineDoubleKeyFrame KeyTime="00:00:2" Value=".5,.5"/> 
        <SplineDoubleKeyFrame KeyTime="00:00:4" Value="1,0"/> 
        <SplineDoubleKeyFrame KeyTime="00:00:6" Value=".5,.5"/> 
       </DoubleAnimationUsingKeyFrames> 
       <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" 
              Storyboard.TargetName="Path1" 
              Storyboard.TargetProperty="(Path.Stroke).(LinearGradientBrush.EndPoint)"> 
        <SplineDoubleKeyFrame KeyTime="00:00:0" Value="1,0"/> 
        <SplineDoubleKeyFrame KeyTime="00:00:2" Value=".5,.5"/> 
        <SplineDoubleKeyFrame KeyTime="00:00:4" Value="0,1"/> 
        <SplineDoubleKeyFrame KeyTime="00:00:6" Value=".5,.5"/> 
       </DoubleAnimationUsingKeyFrames> 
      </Storyboard> 
     </BeginStoryboard> 
    </EventTrigger> 
</UserControl.Triggers> 

回答

2

是。在上面的例子中只需使用「PointAnimationUsingKeyFrames」和「SplinePointKeyFrame」。它應該工作。

+0

謝謝。這工作完美。 – 2010-09-09 20:13:09

相關問題