2011-04-20 69 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