title: Using a resource image in code behind
body: <p>I need to dynamically change the background image applied to one of my buttons, but can't figure out how. The images are added to the project and have their Build Action set to Resource. I've tried the follow:</p>
  
  <pre><code>buttonUnits.Background = new ImageBrush(new BitmapImage(new Uri("/Images/InchDOWN.png",UriKind.Relative)));
  </code></pre>
  
  <p>This compiles successfully, but will crash with a DirectoryNotFoundException saying "Could not find a part of the path 'C:\Images\InchDOWN.png'." </p>
  
  <p>I don't want the app to look for the image on disk. How can I use the image as an embedded resource? I would think it involves changing the Build Action to Embedded Resource, but how do I use this resource in the code behind?</p>