title: BitmapImage.UriSource howto
body: <p>I need to add the background image of a control from code behind. Namely, I wrote the following:</p>
  
  <pre><code>    BitmapImage tmp = new BitmapImage();
      tmp.BeginInit();
      tmp.UriSource = new Uri(@"../images/card.png", UriKind.Relative);
      tmp.DecodePixelWidth = 240;
      tmp.EndInit();
      this.bg.Source = tmp;
  </code></pre>
  
  <p>The problem is that I am not able to get the Uri source right. The structure of the project is as follows: the images folder is at root level (say, at the same level of the Resources one) and card.png has its build action set to Resource and is always copied to the output folder. My class is in another folder, at the same level of the "images" one. What am I missing? Thanks.</p>