title: issue in Deleting Storyboard in wpf
body: <pre><code>&lt;Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="QWERTY.animation"
  x:Name="Window"
  Title="animation"
  Width="640" Height="480"&gt;
  &lt;Window.Resources&gt;
      &lt;Storyboard x:Key="Animation"&gt;
          &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.FontSize)" Storyboard.TargetName="btn_1"&gt;
              &lt;EasingDoubleKeyFrame KeyTime="0" Value="11"/&gt;
              &lt;EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="10.667"/&gt;
          &lt;/DoubleAnimationUsingKeyFrames&gt;
          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.FontWeight)" Storyboard.TargetName="btn_1"&gt;
              &lt;DiscreteObjectKeyFrame KeyTime="0"&gt;
                  &lt;DiscreteObjectKeyFrame.Value&gt;
                      &lt;FontWeight&gt;Normal&lt;/FontWeight&gt;
                  &lt;/DiscreteObjectKeyFrame.Value&gt;
              &lt;/DiscreteObjectKeyFrame&gt;
              &lt;DiscreteObjectKeyFrame KeyTime="0:0:0.3"&gt;
                  &lt;DiscreteObjectKeyFrame.Value&gt;
                      &lt;FontWeight&gt;Bold&lt;/FontWeight&gt;
                  &lt;/DiscreteObjectKeyFrame.Value&gt;
              &lt;/DiscreteObjectKeyFrame&gt;
          &lt;/ObjectAnimationUsingKeyFrames&gt;
          &lt;ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="btn_1"&gt;
              &lt;EasingColorKeyFrame KeyTime="0" Value="#FFEAF0ED"/&gt;
              &lt;EasingColorKeyFrame KeyTime="0:0:0.3" Value="#FF106285"/&gt;
          &lt;/ColorAnimationUsingKeyFrames&gt;
      &lt;/Storyboard&gt;
  &lt;/Window.Resources&gt;
  
  &lt;Grid x:Name="LayoutRoot"&gt;
      &lt;Button x:Name="btn_2" Content="B" Height="55" Margin="236,98,0,0" VerticalAlignment="Top" Click="btn_2_Click" HorizontalAlignment="Left" Width="72" /&gt;
      &lt;Button x:Name="btn_1" Content="A" Height="55" Margin="115,98,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="72" Click="btn_1_Click"&gt;
          &lt;Button.Background&gt;
              &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                  &lt;GradientStop Color="White" Offset="0"/&gt;
                  &lt;GradientStop Color="#FFEAF0ED" Offset="0.9"/&gt;
              &lt;/LinearGradientBrush&gt;
          &lt;/Button.Background&gt;
      &lt;/Button&gt;
      &lt;Button Content="Remove" HorizontalAlignment="Left" Margin="173,179,0,217" Width="75" Click="Button_Click" /&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>The design will be like below
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/0XXJb.png" alt="enter image description here"></p>
  
  <pre><code>public partial class animation : Window
          {
      Storyboard SB;
      public animation()
      {
          this.InitializeComponent();         
      }
  
      public void Animate(string name)
      {
          SB = (Storyboard)(FindResource("Animation"));
          Storyboard.SetTargetName(SB.Children[0], name);
          Storyboard.SetTargetName(SB.Children[1], name);
          Storyboard.SetTargetName(SB.Children[2], name);
          SB.Begin();            
      }
      private void btn_1_Click(object sender, RoutedEventArgs e)
      {
          Button Btn_1 = (Button)sender;
          Animate(btn_1.Name);
      }
  
      private void btn_2_Click(object sender, RoutedEventArgs e)
      {
          Button Btn_2 = (Button)sender;
          Animate(Btn_2.Name);
      }
  
      private void Button_Click(object sender, RoutedEventArgs e)
      {
          SB.Remove();
      }
  }
  </code></pre>
  
  <p>It's output will be like below</p>
  
  <p><img src="https://i.stack.imgur.com/kwQ3C.png" alt="Output"></p>
  
  <p>The above result is after i clicked two buttons one by one.Then I clicked the remove button,only the <strong>button B</strong> animation is removed. But i want to remove  <strong>button A and button B animation</strong> by clicking of remove button.</p>