title: Add Image to StackPanel in programmatically
body: <p>I am trying to programmatically generate a <code>StackPanel</code> and add an <code>Image</code> to the <code>StackPanel</code>. Somehow I get an empty StackPanel. I do not see anything wrong with my code, and it didn't throw any exception: </p>
  
  <pre><code>StackPanel Sp = new StackPanel();
  Sp.Orientation = Orientation.Horizontal;
  
  Image Img = new Image();
  BitmapImage BitImg = new BitmapImage(new Uri(
      "/MyProject;component/Images/image1.png", UriKind.Relative));
  Img.Source = BitImg;
  
  Sp.Children.Add(Img);
  </code></pre>
  
  <p><strong>[EDIT]</strong></p>
  
  <p>I tried another way to add the Image and it works. It intrigues me because they seems to me essentially the same thing:</p>
  
  <p>The following code <strong>WORKS</strong> (show image):</p>
  
  <pre><code>Image Img = new Image();
  Img.Source = new BitmapImage(new Uri(
               "pack://application:,,,/MyProject;component/Images/image1.png"));
  </code></pre>
  
  <p>The following code does <strong>NOT WORK</strong> (image missing):</p>
  
  <pre><code>Image Img = new Image();
  BitmapImage ImgSource = new BitmapImage(new Uri(
      "pack://application:,,,/MyProject;component/Images/image1.png",
      UriKind.Relative));
  Img.Source = BitImg;
  </code></pre>
  
  <p>Why are they different??</p>