title: Setting WPF Window Background Image at App Start Up
body: <p>I have an application that shows a different background images according to environment state, this app is launched at user logon via Windows Registry (HKEY_CURRENT_USER).<br> After user login the application is launched but it crashes afterward, complaining that the Uri for the image is not valid. <br>Notably if the application is launched manually by the user (i.e. double clicking) all works fine, and the corresponding image is successfully loaded.<br>
  Images are configured with <em>Build Action = None, and Copy to output directory= Copy if newer</em>.</p>
  
  <p>This markup in my main window:</p>
  
  <pre><code>&lt;Window.Background&gt;
      &lt;ImageBrush x:Name="imgBackground" &gt;&lt;/ImageBrush&gt;
  &lt;/Window.Background&gt;
  </code></pre>
  
  <p>Then in codebehind I want to set the corresponding image:</p>
  
  <pre><code>imgBackground.ImageSource = 
       new BitmapImage(new Uri(@"Resources\Background.png",UriKind.RelativeOrAbsolute));
  </code></pre>
  
  <p>Images are configured with <em>Build Action = None, and Copy to output directory= Copy if newer</em>.</p>