سلام
من از یک روش استفاده میکنم که با یک مثال این روش رو توضیح میدم
فرض کنیم StoryBoard ما این باشه
<Storyboard x:Key="OnClick1" >
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width )" Storyboard.TargetName="Window">
<EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="900"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
حالا با کد زیر زمان رو نصف میکنم
System.Windows.Media.Animation.Storyboard sb = FindResource("OnClick1") as System.Windows.Media.Animation.Storyboard;
sb.SpeedRatio = 2;
کد زیر اونو دوبرابر میکنه
System.Windows.Media.Animation.Storyboard sb = FindResource("OnClick1") as System.Windows.Media.Animation.Storyboard;
sb.SpeedRatio = 0.5;
راه دوم
var sb = FindResource("OnClick1") as System.Windows.Media.Animation.Storyboard;
var ani = sb.Children[0] as System.Windows.Media.Animation.DoubleAnimationUsin gKeyFrames;
var keyFrames = ani.KeyFrames[0];
keyFrames.KeyTime = System.Windows.Media.Animation.KeyTime.FromTimeSpa n(new TimeSpan(0, 0, 0, 20));
نکته ممکنه تعداد DoubleAnimationUsingKeyFrames بیش از یک مورد باشه ( مثل مثال خودتون)
مثلا
<Storyboard x:Key="OnClick1" >
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransf orm).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="button1">
<EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1.279"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransf orm).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="button1">
<EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1.514"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransf orm).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="button1">
<EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="12"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransf orm).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="button1">
<EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="9"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
کدش به این شکل میشه
var sb = FindResource("OnClick1") as System.Windows.Media.Animation.Storyboard;
var ani = sb.Children[0] as System.Windows.Media.Animation.DoubleAnimationUsin gKeyFrames;
var keyFrames = ani.KeyFrames[0];
keyFrames.KeyTime = System.Windows.Media.Animation.KeyTime.FromTimeSpa n(new TimeSpan(0, 0, 0, 20));
ani = sb.Children[1] as System.Windows.Media.Animation.DoubleAnimationUsin gKeyFrames;
keyFrames = ani.KeyFrames[0];
keyFrames.KeyTime = System.Windows.Media.Animation.KeyTime.FromTimeSpa n(new TimeSpan(0, 0, 0, 20));
ani = sb.Children[2] as System.Windows.Media.Animation.DoubleAnimationUsin gKeyFrames;
keyFrames = ani.KeyFrames[0];
keyFrames.KeyTime = System.Windows.Media.Animation.KeyTime.FromTimeSpa n(new TimeSpan(0, 0, 0, 20));
ani = sb.Children[3] as System.Windows.Media.Animation.DoubleAnimationUsin gKeyFrames;
keyFrames = ani.KeyFrames[0];
keyFrames.KeyTime = System.Windows.Media.Animation.KeyTime.FromTimeSpa n(new TimeSpan(0, 0, 0, 20));
یا به شکل خلاصه
var sb = FindResource("OnClick1") as System.Windows.Media.Animation.Storyboard;
foreach (var ani in sb.Children)
{
var keyFrames = (ani as System.Windows.Media.Animation.DoubleAnimationUsin gKeyFrames).KeyFrames[0];
keyFrames.KeyTime = System.Windows.Media.Animation.KeyTime.FromTimeSpa n(new TimeSpan(0, 0, 0, 20));
}
امیدوارم منظور رو رسونده باشم
البته من پیشنهاد میکنم در مواقعی که نیاز دارید انیمیشن متغییر داشته باشید کلا اونو در code Behind بنویسید
در لینک زیر یک مثال از این مسئله وجود داره
https://barnamenevis.org/showthread.p...86%D8%B1%DB%8C