I have this code:
public partial class MainWindow : Window
{
Storyboard st_common = new Storyboard();
DoubleAnimation anim1 = new DoubleAnimation();
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
anim1.Duration = new Duration(TimeSpan.FromSeconds(5));
anim1.From = 10.0;
anim1.To = 100.0;
st_common.Children.Add(anim1);
Storyboard.SetTargetName(anim1, r1.Name);
Storyboard.SetTargetProperty(anim1, new PropertyPath(Canvas.TopProperty));
st_common.Begin(this);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
r1.SetValue(Canvas.TopProperty, 300.0);
r2.SetValue(Canvas.TopProperty, 300.0);
}
}
Why does SetValue
method not work for r1 element after animation? (r1 and r2 are rectangles)