title: Changing wpf image source to a jpg on runtime that is not a resource
body: <p>I have a personal movieapp that downloads pictures runtime, and I want to display the images instead of a placeholder image I put (If no picture is available)</p>
  
  <p>The code I found that should do the trick changes nothing</p>
  
  <p>I have this WPF image control</p>
  
  <pre><code>&lt;Image Name="MovieImage" Height="Auto" Width="Auto" Grid.Column="2" Grid.Row="0" Grid.ColumnSpan="2" Grid.RowSpan="4" Source="NoPhotoAvailable.jpg" /&gt;
  </code></pre>
  
  <p>and then I have </p>
  
  <pre><code>public void MovieList_SelectionChanged(Movie SelectedMovie)
      {
          this.SelectedMovie = SelectedMovie;
          BitmapImage bi = new BitmapImage();
  
          bi.BeginInit();
          bi.UriSource = new Uri("/155.jpg", UriKind.RelativeOrAbsolute);
          bi.EndInit();
          Console.WriteLine(bi.UriSource.ToString());
  
          MWV.MovieImage.Source = bi;
      }
  </code></pre>
  
  <p>Where MWV is where the image control is at</p>
  
  <p>The image is placed in the apps folder and named 155.jpg but nothing is shown at all</p>
  
  <p>I found alot of examples inhere that suggests that this should be pretty close to the solution but apprently not correct</p>
  
  <p>Solution:</p>
  
  <pre><code>        public void MovieList_SelectionChanged(Movie SelectedMovie)
      {
          if (MovieCount == 0)
          {
              Console.WriteLine(MovieCount.ToString());
              MWV.MovieImage.Source = new BitmapImage(new Uri("NoPhotoAvailable.jpg", UriKind.RelativeOrAbsolute));
          }
          else
          {
              this.SelectedMovie = SelectedMovie;
              BitmapImage bi = new BitmapImage();
  
              bi.BeginInit();
              string path = Path.Combine(Path.GetDirectoryName(typeof(MainWindowController).Assembly.Location), this.SelectedMovie.TMDBID.ToString() + ".jpg");
              bi.UriSource = new Uri(path, UriKind.RelativeOrAbsolute);
              bi.EndInit();
              Console.WriteLine(bi.UriSource.ToString());
  
              MWV.MovieImage.Source = bi;
          }
      }
  </code></pre>