title: WPF Animation performance descrease over time
body: <p>i have two animation:</p>
  
  <pre><code>    &lt;Storyboard x:Key="ChangeLayout"&gt;
          &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="currentContent"&gt;
              &lt;EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="900"/&gt;
              &lt;EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"&gt;
                  &lt;EasingDoubleKeyFrame.EasingFunction&gt;
                      &lt;CircleEase EasingMode="EaseInOut"/&gt;
                  &lt;/EasingDoubleKeyFrame.EasingFunction&gt;
              &lt;/EasingDoubleKeyFrame&gt;
          &lt;/DoubleAnimationUsingKeyFrames&gt;
      &lt;/Storyboard&gt;
      &lt;Storyboard x:Key="HideLayout"&gt;
          &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="currentContent"&gt;
              &lt;EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="-900"&gt;
                  &lt;EasingDoubleKeyFrame.EasingFunction&gt;
                      &lt;CircleEase EasingMode="EaseInOut"/&gt;
                  &lt;/EasingDoubleKeyFrame.EasingFunction&gt;
              &lt;/EasingDoubleKeyFrame&gt;
          &lt;/DoubleAnimationUsingKeyFrames&gt;
      &lt;/Storyboard&gt;
  </code></pre>
  
  <p>And code that begin they:</p>
  
  <pre><code>private void btnUser_Click(object sender, RoutedEventArgs e)
      {
          if (currentContent.Content != null)
              if (currentContent.Content.GetType() == typeof(Layouts.User))
                  return;
          ((hl.Children[0] as DoubleAnimationUsingKeyFrames).KeyFrames[0] as EasingDoubleKeyFrame).Value = -this.ActualWidth;
          hl.Completed += (_sender, _e) =&gt;
          {
              currentContent.Content = new Layouts.User();
              cl.Completed += (ssender, ee) =&gt;
                  {
                      btnMusic.Opacity = 0.5;
                      btnUser.Opacity = 0.9;
                  };
              cl.Begin();
          };
          hl.Begin();
      }
      private void btnMusic_Click(object sender, RoutedEventArgs e)
      {
          if (currentContent.Content != null)
              if (currentContent.Content.GetType() == typeof(Layouts.Music))
                  return;
          ((hl.Children[0] as DoubleAnimationUsingKeyFrames).KeyFrames[0] as EasingDoubleKeyFrame).Value = -this.ActualWidth;
          hl.Completed += (_sender, _e) =&gt;
              {
                  if (Layouts.Music.CurrentMusic == null)
                  {
                      Layouts.Music.CurrentMusic = new Layouts.Music();
                      Layouts.Music.CurrentMusic.GetMusic();
                  }
                  currentContent.Content = Layouts.Music.CurrentMusic;
                  cl.Completed += (ssender, ee) =&gt;
                      {
                          btnUser.Opacity = 0.5;
                          btnMusic.Opacity = 0.8;
                      };
  
                  cl.Begin();
              };
          hl.Begin();
      }
  </code></pre>
  
  <p>After a few switches between user and content of music, ChangeLayout animation begins very slow and laggy and animated according to the WPF Performance Suite FPS animation after switching drops from 500 + to a maximum of 4eh ...
  Can't find any solution for this =(</p>
  
  <p>Sry for my english, i am studying so far.</p>