title: C#, binding new BitmapImage, WPF MVVM
body: <p>Im new in WPF MVVM and i have a problem with binding a new <code>BitmapImage</code> to <code>Image.Source</code> control. </p>
  
  <p>Binding image from filepath is pretty easy, but how bind new <code>Bitmap</code> or <code>BitmapImage</code> to <code>Image</code> label in WPF?</p>
  
  <p>My scenerio:</p>
  
  <p><strong>I have an method to do something with image (it is hide in <code>Model</code> folder in <code>Class</code> for methods for working on images:</strong></p>
  
  <pre><code>static public BitmapImage Init(Bitmap bmp)
      {
          //Do stuff
  
          return BitmapConversion.Bitmap2BitmapImage(newImage); 
  
          //BitmapConversion is my own class for converting images
      }
  </code></pre>
  
  <p>In this section, i made what i want to do with my Bitmap and return <code>BitmapImage</code>. </p>
  
  <p>In <strong>ViewModel</strong>, i have this, opening an image and Init function that i want to:</p>
  
  <pre><code>namespace Test.ViewModels
  {
      class ViewModel
      {
          public string filepath { get; set; }
  
          public ViewModel()
          {
  
              OpenFileDialog openPicture = new OpenFileDialog();
              openPicture.Filter = "Image files|*.bmp;*.jpg;*.gif;*.png;*.tif|All files|*.*";
              openPicture.FilterIndex = 1;
  
              if (openPicture.ShowDialog() == true) 
              {
                  filepath = openPicture.FileName;
  
                  Model.Init(new Bitmap(filepath)); //init function from above
              }
  
          }
  
          public string DisplayedImage
          {
              get { return filepath; }
          }
  
      }
  </code></pre>
  
  <p>My <strong>View</strong> looks like:</p>
  
  <pre><code>&lt;!-- row1 --&gt;
  &lt;Image Source="{Binding DisplayedImage}" /&gt;
  
  &lt;!-- row2 --&gt;
  &lt;Image Source ={Binding ?}" /&gt;
  </code></pre>
  
  <p>My question is, how to bind properly object like BitmapImage to source of Image label?</p>
  
  <p>Thanks for any advices</p>