title: Fade out from one image and fade in another
body: <p>I'm trying to get one image to fade out completely, then fade in another image with Storyboards, but I can't figure it out. I have the fade out part working, but I can't find a way for it to change the Image and fade back in smoothly. I have yet to figure out a way for it to fade back in with one button press, and have the image change dynamically. Even if I change the source path, the image doesn't update. I'm trying to do all this with as much XAML as possible, rather than code-behind.</p>
  
  <p><strong>EDIT</strong>
  I figured out how to make it fade back in, however, changing the image source doesn't change the image. I need some help on this.</p>
  
  <p>This is what I have right now</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;Storyboard x:Key="FadeOut" Completed="Storyboard1_Completed"&gt;
          &lt;DoubleAnimation From="1" To="0" Storyboard.TargetName ="Image1" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:5"/&gt;
      &lt;/Storyboard&gt;
      &lt;Storyboard x:Key="FadeIn" Name="FadeIn"&gt;
          &lt;DoubleAnimation From="0" To="1" Storyboard.TargetName ="Image1" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:5"/&gt;
      &lt;/Storyboard&gt;
  &lt;/Window.Resources&gt;
  
  &lt;Grid HorizontalAlignment="Center"&gt;
  
      &lt;Image Source="{Binding Path=imagePath}" Margin="0,0,0,28" Name="Image1"/&gt;
      &lt;Button Content="Fade" Height="23" Margin="0,284,341,0" Name="button1" Width="162" Click="button1_Click"/&gt;
  
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p>C#</p>
  
  <pre><code>public partial class MainWindow : Window
  {
  
      public String imagePath { get; set; }
  
      public MainWindow()
      {
          imagePath = "1.png";
          InitializeComponent();
  
      }
  
      private void Storyboard1_Completed(object sender, EventArgs e)
      {
  
          imagePath = "2.png";
          Storyboard stbFadeOut = (Storyboard)FindResource("FadeIn");
          stbFadeOut.Begin();
      }
  
      private void button1_Click(object sender, RoutedEventArgs e)
      {
          Storyboard stbFadeOut = (Storyboard)FindResource("FadeOut");
          stbFadeOut.Begin();
  
      }
  }
  </code></pre>