title: Adding a fadeOut to an image in with C# in a windows store app
body: <p>I write a windows store app with C# and XAML and I try to add a fadeOut animation to an image.</p>
  
  <p>If i add the animation in XAML Code like this, it works and I can start the animation with 'RemoveMatchsticks.Begin();' in C#</p>
  
  <pre><code>&lt;StackPanel Orientation="Horizontal" x:Name="Matches" Height="200"&gt;
      &lt;StackPanel.Resources&gt;
          &lt;Storyboard x:Name="RemoveMatchsticks"&gt;
              &lt;FadeOutThemeAnimation  Storyboard.TargetName="matchstick" /&gt;
          &lt;/Storyboard&gt;
      &lt;/StackPanel.Resources&gt;
      &lt;Image Source="Assets/Match.png" x:Name="matchstick" /&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>But I need to add an animation in C#. For testing I have the same picture in XAML</p>
  
  <pre><code>&lt;StackPanel Orientation="Horizontal" x:Name="Matches" Height="200"&gt;
      &lt;Image Source="Assets/Match.png" x:Name="matchstick" /&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>and the following c#-Code</p>
  
  <pre><code>Storyboard storyboard = new Storyboard();
  FadeOutThemeAnimation fadeOut = new FadeOutThemeAnimation();
  Duration duration = new Duration(TimeSpan.FromSeconds(2));
  fadeOut.Duration = duration;
  storyboard.Duration = duration;
  
  Storyboard.SetTargetProperty(fadeOut, "Opacity");
  Storyboard.SetTarget(fadeOut, matchstick);
  storyboard.Begin();
  </code></pre>
  
  <p>It doesn't work. I think, the targetProperty in SetTargetProperty is wrong, but I don't know the correct way and there aren't any error messages.</p>
  
  <p>Thanks,
  Klaus</p>