C# c wpf在加载时将DoubleAnimation更改为(在中)

C# c wpf在加载时将DoubleAnimation更改为(在中),c#,wpf,doubleanimation,C#,Wpf,Doubleanimation,我使用此代码从左到右设置图像动画 但我想把窗户宽度设为=100 如何在加载或调整窗口大小时将DoubleAnimation更改为 xaml: 如果我正确理解了您的问题,您希望在codebehind中将to更改为不同的值,如下所示: Storyboard sb = this.FindResource("PlayAnimation") as Storyboard; (sb.Children[0] as DoubleAnimation).To = 200; Storyboard.Set

我使用此代码从左到右设置图像动画 但我想把窗户宽度设为=100 如何在加载或调整窗口大小时将DoubleAnimation更改为

xaml:


如果我正确理解了您的问题,您希望在codebehind中将to更改为不同的值,如下所示:

Storyboard sb = this.FindResource("PlayAnimation") as Storyboard;        
(sb.Children[0] as DoubleAnimation).To = 200;
Storyboard.SetTarget(sb, this.image2);
sb.Begin();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
  Storyboard sb = this.FindResource("PlayAnimation") as Storyboard;        
  Storyboard.SetTarget(sb, this.image2);
  sb.Begin();
}
Storyboard sb = this.FindResource("PlayAnimation") as Storyboard;        
(sb.Children[0] as DoubleAnimation).To = 200;
Storyboard.SetTarget(sb, this.image2);
sb.Begin();