title: Wpf, .resx resource file. Accessing bmp
body: <p>I have a Wpf application project called <code>WpfTest</code> which references <code>WpfTestLib</code> (A class library). </p>
  
  <p>WpfTestLib has a resources file <code>MyResources.resx</code> in a project folder called <code>Resources</code>. <code>MyResources</code> contains a single bmp, bar.bmp. The resource name is <code>bar</code>.</p>
  
  <p>In <code>MyResources.Designer.cs</code> I can see </p>
  
  <p><code>namespace WpfTestLib.Resources {</code></p>
  
  <p>and</p>
  
  <p><code>public class MyResources {</code></p>
  
  <p>and </p>
  
  <p><code>public static System.Drawing.Bitmap bar {</code></p>
  
  <p>I've tried to get the image in code by:</p>
  
  <pre><code>BitmapImage image = new BitmapImage();
  image.BeginInit();
  image.UriSource = new Uri(@"/WpfTestLib;component/Resources/MyResources/bar", UriKind.Relative);
  </code></pre>
  
  <p>I've tried various combinations for the <code>Uri</code>, but no luck. Any ideas? I can get the bar if I add it as an image to the project, with a type of resource. But in this case I want to access it as part of a resource file.</p>
  
  <p>Thanks</p>
  
  <p>Edit: Actually it's two questions. I have answers to both, but not the bit in the middle that holds it together. </p>
  
  <p>So I can retrieve the image in code using <code>MyResources.bar</code>, which returns a <code>System.Drawing.Bitmap</code></p>
  
  <p>I can also set the my WPF Image to a resource image using the Uri format shown above. What I can't do is initialize a WPF Image with a <code>System.Drawing.Bitmap</code>, nor can I find a mapping <code>Uri</code> for a .resx. Hope that helps (you to help me :) )</p>