title: Silverlight URI loading Image
body: <p>I am trying to load an Image in Silverlight, but i keep getting a null pointer exception when i assign it to this.Image1.Source. I've looked over similiar stack questions, but none of them solve the problem. My image file is in a folder right next to the xap file.</p>
  
  <pre><code>    public MainPage()
      {
          Uri uri = new Uri("Content/button.png", UriKind.Relative);
          var image = new BitmapImage { UriSource = new Uri("Content/button.png", UriKind.Relative) };
          try
          {
              BitmapImage img = new BitmapImage(uri);
              this.image1.Source = image;
          }
          catch (Exception e)
          {
              string problem = e.Message;
          }
  
          InitializeComponent();
      }
  </code></pre>