title: Referring to image file in WPF project in Visual Studio
body: <p>I'd like to load images into a WPF project with a short pathname. Details follow.</p>
  
  <p>I've got a WPF solution that looks like this:</p>
  
  <pre><code>Solution 'GB" (16 projects)   
     ABApp
       Properties
       References
       ...   ...   
     ImageApp
       Properties
       References
       images
          mona.jpg
       App.xaml
          App.xaml.cs
       Window1.xaml
          Window1.xaml.cs
  </code></pre>
  
  <p>I want to look at the <code>ImageApp</code> project. </p>
  
  <p>The <code>App.xaml</code> file looks like this:</p>
  
  <pre><code>&lt;Application x:Class="GB.App"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           StartupUri="Window1.xaml"&gt;
      &lt;Application.Resources&gt;
      &lt;/Application.Resources&gt;
  &lt;/Application&gt;
  </code></pre>
  
  <p>and <code>App.xaml.cs</code> simply defines the class <code>App</code> to derive from <code>Application</code>. </p>
  
  <p>The <code>Window1.xaml</code> file constructs a UI, and then <code>Window1.xaml.cs</code> builds a drawing area in which various image stuff will be displayed. </p>
  
  <p>Inside that C# file, to load up the image <code>images/mona.jpg</code> that I want to display, I end up writing something like this:</p>
  
  <pre><code>        Image myImage;
  
          BitmapImage myBitmapImage = new BitmapImage();
  
          myBitmapImage.BeginInit();
          myBitmapImage.UriSource = 
               new Uri("../../images/mona.jpg", UriKind.RelativeOrAbsolute);
          myBitmapImage.EndInit();
          //set image source
          FormatConvertedBitmap newFormatedBitmapSource = new FormatConvertedBitmap();
  
          newFormatedBitmapSource.BeginInit();
          newFormatedBitmapSource.Source = myBitmapImage;
          newFormatedBitmapSource.DestinationFormat = PixelFormats.Bgra32;
          newFormatedBitmapSource.EndInit();
          bmpSource = newFormatedBitmapSource;
          myImage.Source = bmpSource;
          BuildRenderTransform();
  </code></pre>
  
  <p>(I apologize for that code -- it's a kind of simplification of what's really going on, so it may not be letter perfect.)</p>
  
  <p>My question is about the Uri: I have to write <code>../../</code> at the front of the Uri so that the executing program (which ends up in <code>ImageApp/bin/Debug</code>) knows it has to go up two levels and then down into the <code>images</code> folder. Is there some way that I can just write something like <code>new Uri("images/mona.jpg", ...)</code> instead? Can I tell WPF that the source directory should be used as the starting path for relative searches? </p>
  
  <p>I confess, the whole Uri thing is mostly baffling to me, despite my having read the microsoft help articles and several StackExchange questions/answers..</p>
  
  <p>I have the suspicion (and vague memory) that by adding something to the xaml for the project, I can make this happen, but I just can't seem to do it. </p>
  
  <p>Any ideas? </p>