title: Updating Bitmap from BackgroundWorker in MVVM/WPF
body: <p>I'm trying to update a BitmapImage in the UI from a BackgroundWorker thread. I know enough about background workers to generally set them up, and how to use an ObservableCollection to update a list from a BackgroundWorker, but I'm struggling getting the image to update.</p>
  
  <p>When I set </p>
  
  <p>So far it looks like this:</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Image Source="{Binding ImageSource}" /&gt;
  </code></pre>
  
  <p>ViewModel:</p>
  
  <pre><code>public class ViewModel : INotifyPropertyChanged
  {
      public event PropertyChangedEventHandler PropertyChanged;
      public void NotifyPropertyChanged(string propertyName)
      {
          if (PropertyChanged != null)
          {
              PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  
      private BitmapImage ImageSource_;
      public BitmapImage ImageSource
      {
          get { return ImageSource_; }
          set { ImageSource_= value; NotifyPropertyChanged("ImageSource"); }
      }
  
      private BackgroundWorker UpdateImageBGW = new BackgroundWorker();
  
      public ViewModel()
      {
          // this works fine
          ImageSource = UpdateImage();
  
          UpdateImageBGW.DoWork += new DoWorkEventHandler(UpdateImage_DoWork);
          UpdateImageBGW.RunWorkerAsync();
      }
  
      private void UpdateImage_DoWork(object sender, DoWorkEventArgs e)
      {
          // this gets called fine and grabs the updated image, but setting it to
          // ImageSource never updates the UI
          ImageSource = UpdateImage();
      }
  }
  </code></pre>