title: WPF C# Image resource in listBox
body: <p>I am having trouble getting an image, as a resource, to show in a listBox element.</p>
  
  <p>It looks like a lot of people are having trouble with it, it seems difficult to do, when to me it sounds like something that would be very common and easy to do.</p>
  
  <p>I've got a file called 'home_icon.jpg' in a folder called 'images' within my resource, so: <code>images/home_icon.jpg</code>.</p>
  
  <p>I've got a list box, for which the full code is shown below:</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;ListBox Height="253" HorizontalAlignment="Left" Margin="10,46,0,0" Name="listBox1" VerticalAlignment="Top" Width="481"&gt;
  
              &lt;ListBoxItem&gt;
  
                  &lt;StackPanel Orientation="Horizontal" &gt;
                      &lt;Image Source="" Width="50" Opacity="50" /&gt;
                      &lt;TextBlock Margin="0,5,0,0" Text="13 Scale Hall Lane" Width="425" /&gt;
                  &lt;/StackPanel&gt;
  
              &lt;/ListBoxItem&gt;
  
          &lt;/ListBox&gt;
          &lt;Label Content="Welcome to the house manager" Height="28" HorizontalAlignment="Left" Margin="14,12,0,0" Name="label1" VerticalAlignment="Top" /&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>I've read a bit online, and I've learned to set the "Build action" for the image to "Resource.</p>
  
  <p><img src="https://i.stack.imgur.com/O63xf.png" alt="Build action for home_icon.jpg"></p>
  
  <p>Here is the view of my solution explorer, showing the image in a folder:
  <img src="https://i.stack.imgur.com/lL7bz.png" alt="Solution explorer"></p>
  
  <p>What do I put in the Source="" attribute for the Image on the stackpanel for it to show my image?</p>
  
  <p>I've tried looking at the following resources and things just aren't sticking:</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/aa970069.aspx#The_Pack_URI_Scheme" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa970069.aspx#The_Pack_URI_Scheme</a></p>
  
  <p><a href="http://channel9.msdn.com/forums/TechOff/416423-WPF--How-to-load-image-from-resource" rel="nofollow noreferrer">http://channel9.msdn.com/forums/TechOff/416423-WPF--How-to-load-image-from-resource</a></p>
  
  <p><a href="https://stackoverflow.com/questions/347614/wpf-image-resources">WPF image resources</a></p>