How to change speed of animations globally in WPF application?
I'd like to add the ability to globally change the speed of all animations in my WPF application. For example, some users might dislike animations so they'd perhaps cut the durations to a quarter of the normal. During a demo, you might want to double the durations so they're emphasized.
I figured out how t开发者_C百科o adjust the DesiredFrameRate property globally, but I can't figure out how to adjust the SpeedRatio property globally (i.e. so that the SpeedRatio applies to all timelines and not just one specific Timeline at a time). The animations themselves might come from all sorts of places (triggers, Visual State Manager, etc.)
Any thoughts?
You can use resource in all your animatons:
<KeyTime x:Key="AnimationTime">0</KeyTime>
<Storyboard x:Key="Storyboard1">
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBoxBase.Background).(SolidColorBrush.Color)" Storyboard.TargetName="{x:Null}">
<EasingColorKeyFrame KeyTime="{StaticResource AnimationTime}" Value="Red"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
精彩评论