title: ImageSource from a relative resource
body: <p>I'm trying to use a local resource to put an icon inside a Button. (C# Visual Studio 2012)</p>
  
  <p>Directly inside my project i have a folder called "Resources" which contains "Icons/MyIcon.png"</p>
  
  <p>The following code works (but is not using a relative path)</p>
  
  <pre><code>&lt;Button Width="20" Height="20"&gt;
    &lt;Button.Background&gt;
          &lt;ImageBrush ImageSource="C:\Documents\MyProject\Resources\Icons\MyIcon.png"&gt;
            &lt;/ImageBrush&gt;
        &lt;/Button.Background&gt;
  </code></pre>
  
  <p></p>
  
  <p>However, i want it to use a relative path... so i tried the following</p>
  
  <pre><code>  &lt;ImageBrush ImageSource="..\MyProject\Resources\Icons\MyIcon.png"&gt;
  </code></pre>
  
  <p>It compiles, but then gives me the error:</p>
  
  <pre><code>{"Cannot locate resource 'myproject/resources/icons/myicon.png'."}
  </code></pre>
  
  <p>Then i found an article that talked about referencing the project and said to do:</p>
  
  <pre><code>"/[ assembly name ];component[ path within the project ]"
  </code></pre>
  
  <p>so i tried that:</p>
  
  <pre><code>&lt;ImageBrush ImageSource="/MyProject;component\Resources\Icons\MyIcon.png"&gt;
  </code></pre>
  
  <p>But it doesn't work.</p>
  
  <p>It DOES show up in the GUI-Builder... but when i actually try to "debug" the code... it fails to run.</p>
  
  <p>If i change the path at all by adding '123' for example:</p>
  
  <pre><code> &lt;ImageBrush ImageSource="/MyProject;component\Resources\Icons\MyIcon123.png"&gt;
  </code></pre>
  
  <p>i get a pre-compile error: "cannot find the file specified".
  Once i remove the '123' the error goes away. And the icon again is displayed in the Form.
  But when i run... i still get:</p>
  
  <pre><code>{"Cannot locate resource 'resources/icons/myicon.png'."}
  </code></pre>
  
  <p>What is going on? Why can it only find the resource BEFORE it runs? and not when i actually start?</p>