2011-04-20 70 views
3

我將多個用戶控件添加到畫布。每個控件都有自己的故事板,可以在加載時執行。我注意到它在執行20秒動畫時非常波濤洶洶。這不是非常複雜,我預計會有更好的表現。任何我應該尋找的陷阱?這是一個故事板樣本:WPF用戶控件與故事板動畫是生澀/雜亂

<Storyboard x:Key="mystoryboard" RepeatBehavior="Forever"> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(BlurEffect.Radius)" Storyboard.TargetName="itemgroup"> 
      <SplineDoubleKeyFrame KeyTime="0" Value="30"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:4" Value="0"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:8" Value="0"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:10" Value="30"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="itemgroup"> 
      <SplineDoubleKeyFrame KeyTime="0" Value="0"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:2" Value="0.96"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:4" Value="1"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:7" Value="1"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:8" Value="1"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:10" Value="0"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="itemgroup"> 
      <SplineDoubleKeyFrame KeyTime="0" Value="0.1"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:10" Value="1"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="itemgroup"> 
      <SplineDoubleKeyFrame KeyTime="0" Value="0.1"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:10" Value="1"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="itemgroup"> 
      <SplineDoubleKeyFrame KeyTime="0" Value="-60"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:10" Value="0"/> 
     </DoubleAnimationUsingKeyFrames> 
    </Storyboard> 
+0

注意您的系統資源,看看它是否固定了CPU。另外,更新你的vidya驅動程序。 – Will 2011-04-20 19:28:21

+0

它肯定會增加CPU,但它是我做錯了什麼的B/C? – 2011-04-20 20:13:05

+0

很難分辨。可能與樣條的行爲有關。你應該在一個測試項目中嘗試一個非常簡化的版本,看看一個單一的控制動畫是否表現出相同的行爲。 – Will 2011-04-20 20:53:42

回答

1

我注意到類似的情況,一個相對簡單的畫布上的形狀故事板動畫。對我來說,DropShadowEffect是罪魁禍首,刪除陰影平滑了動畫。你有任何影響應用到你的用戶控件?

+0

這真的很有幫助,我刪除了它的作品平滑的陰影,但由於某種原因,我需要陰影我怎麼能做到這一點? @GregM – Jamaxack 2015-02-18 07:02:50

+1

不幸的是,我應用DropShadowEffect時無法使動畫順利運行。我通過在動畫之前刪除效果並在其結束之後將其添加回來來解決此問題......並不理想。 – 2015-02-18 17:25:17