title: Execute ICommand in VM after Storyboard completed
body: <p>I need to bind my storyboard's Completed to my VM DelegateCommand, so I found <a href="https://stackoverflow.com/questions/30030876/execute-command-after-animation">this topic</a>.</p>
  
  <p>But for some reason it doesn't work for me.
  Help me please figure it out.</p>
  
  <p>My template with storyboard</p>
  
  <pre><code>&lt;Grid.Triggers&gt;
      &lt;EventTrigger RoutedEvent="Button.Click" SourceName="AddButton2"&gt;
          &lt;BeginStoryboard Name="MyBeginStoryboard"&gt;
              &lt;Storyboard 
                  TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" 
                  local1:StoryboardHelper.CompletedCommand="{Binding Path=OpenPanelCommand}"
                  &gt;
                  &lt;DoubleAnimation 
                      Storyboard.TargetName="panelControl" 
                      Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
                      Duration="0:0:01" From="0" To="-700" 
                      /&gt;
              &lt;/Storyboard&gt;
          &lt;/BeginStoryboard&gt;
      &lt;/EventTrigger&gt;
  &lt;/Grid.Triggers&gt;
  </code></pre>
  
  <p>ViewModel constructor, where OpenPanelCommand has a type ICommand:</p>
  
  <pre><code>OpenPanelCommand = new DelegateCommand(() =&gt; { PanelOpened = true; });
  </code></pre>
  
  <p>StoryboardHelper from link above:</p>
  
  <pre><code>public static class StoryboardHelper
  {
      public static readonly DependencyProperty CompletedCommandProperty = DependencyProperty.RegisterAttached("CompletedCommand", typeof(ICommand), typeof(StoryboardHelper), new PropertyMetadata(null, OnCompletedCommandChanged));
      public static readonly DependencyProperty CompletedCommandParameterProperty = DependencyProperty.RegisterAttached("CompletedCommandParameter", typeof(object), typeof(StoryboardHelper), new PropertyMetadata(null));
  
      public static void SetCompletedCommand(DependencyObject o, ICommand value)
      {
          o.SetValue(CompletedCommandProperty, value);
      }
  
      public static ICommand GetCompletedCommand(DependencyObject o)
      {
          return (ICommand)o.GetValue(CompletedCommandProperty);
      }
  
      public static void SetCompletedCommandParameter(DependencyObject o, object value)
      {
          o.SetValue(CompletedCommandParameterProperty, value);
      }
  
      public static object GetCompletedCommandParameter(DependencyObject o)
      {
          return o.GetValue(CompletedCommandParameterProperty);
      }
  
      private static void OnCompletedCommandChanged(object sender, DependencyPropertyChangedEventArgs e)
      {
          var sb = sender as Storyboard;
  
          if (sb != null)
          {
              sb.Completed += (a, b) =&gt;
              {
                  var command = GetCompletedCommand(sb);
  
                  if (command != null)
                  {
                      if (command.CanExecute(GetCompletedCommandParameter(sb)))
                      {
                          command.Execute(GetCompletedCommandParameter(sb));
                      }
                  }
              };
          }
      }
  }
  </code></pre>