title: Run action when c# wpf animation ends
body: <p>I'm learning wpf and at the same time developing an app with it. I'm having a hard time figuring out how i can run something when a doubleanimation (Or other sorts) is done. For instance:</p>
  
  <pre><code>DoubleAnimation myanim = new DoubleAnimation();
  myanim.From = 10;
  myanim.To = 100;
  myanim.Duration = new Duration(TimeSpan.FromSeconds(3));
  myview.BeginAnimation(Button.OpacityPropert, myanim);
  
  //Code to do something when animation ends
  
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  using System.Windows.Media.Animation;
  
  namespace app
  {
  /// &lt;summary&gt;
  /// Interaction logic for MainWindow.xaml
  /// &lt;/summary&gt;
  public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, RoutedEventArgs e)
      {
          DoubleAnimation widthbutton = new DoubleAnimation();
          widthbutton.From = 55;
          widthbutton.To = 100;
          widthbutton.Duration = new Duration(TimeSpan.FromSeconds(1.5));
          button1.BeginAnimation(Button.HeightProperty, widthbutton);
  
          DoubleAnimation widthbutton1 = new DoubleAnimation();
          widthbutton1.From = 155;
          widthbutton1.To = 200;
          widthbutton1.Duration = new Duration(TimeSpan.FromSeconds(1.5));
          button1.BeginAnimation(Button.WidthProperty, widthbutton1);
  
          widthbutton.Completed += new EventHandler(myanim_Completed);
      }
      private void myanim_Completed(object sender, EventArgs e)
      {
          //your completed action here
          MessageBox.Show("Animation done!");
      }
  }
  }
  </code></pre>
  
  <p>How is this accomplishable? I have read quite a few other posts about this, but they all explain it using xaml, however i would like to do it using c# code. Thanks!</p>