具有 Storyboard 动画的 WPF 用户控件不稳定/不稳定

标签 wpf performance animation

我正在向 Canvas 添加多个用户控件。每个控件都有自己的 Storyboard,在加载时执行。我注意到它在执行 20 秒动画时非常不稳定。它并不是非常复杂,我希望有更好的性能。有什么我应该注意的问题吗?这是 Storyboard的示例:

<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>

最佳答案

我注意到 Canvas 上形状相对简单的 Storyboard动画也存在类似情况。对我来说,DropShadowEffect 是罪魁祸首;删除阴影使动画变得平滑。您是否对用户控件应用了任何效果?

关于具有 Storyboard 动画的 WPF 用户控件不稳定/不稳定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5735466/

相关文章:

javascript - html canvas clearRect() 不起作用

c# - 动画受面板限制

c# - 如何将 async/await 与返回 ObservableCollection<T> 的方法一起使用

c# - 仅基于世界坐标将对象投影到场景中

mysql - 从一个表中获取不在另一特定表中的所有 mysql 条目

c# - 获得 Entity Framework 6 的最佳性能,如 Dapper.NET

mysql 性能与 select not in

javascript - 带有 Javascript 回退的 CSS3 过渡

c# - 在组合框中设置项目的焦点

javascript - 点击div切换动画?