title: How to load a image to image control in wpf?
body: <p>I'm developing an application in wpf with mvvm pattern.</p>
  
  <p>in my application, i need to select a image and show in a form and then save it to database.</p>
  
  <p>in the wpf form, i'm using a image control to display the image.</p>
  
  <p>in my view model, I open the file dialog and assign the Image Property.</p>
  
  <pre><code>BitmapImage image;
  public BitmapImage Image
  {
      get { return image; }
      set
      {
          image = value;
          RaisePropertyChanged("Image");
      }
  }
  
  ...
  
  OpenFileDialog file = new OpenFileDialog();
  Nullable&lt;bool&gt; result =file.ShowDialog();
  
  if (File.Exists(file.FileName))
  {
      image = new BitmapImage();
      image.BeginInit();
      image.UriSource = new Uri(file.FileName, UriKind.Absolute);
      image.EndInit();
  }
  </code></pre>
  
  <p>my xaml part is</p>
  
  <pre><code> &lt;Image Height="144" HorizontalAlignment="Left" Source="{Binding Image}"
          Margin="118,144,0,0" Name="imgData" Stretch="Fill" VerticalAlignment="Top" Width="340" /&gt;
  </code></pre>
  
  <p>I'm not able to see the image in the form. How?</p>