In WPF when you try to assign a bitmap to a property that’s bound to a UI element from a worker thread you may get the following error:
“Must create DependencySource on same Thread as the DependencyObject”
A simple way around this problem without having to jump through hoops and dispatch to the UI thread is to just freeze the bitmap before assigning it, like this:
var bitmap = new BitmapImage(new Uri(CurrentImageFilePath));
this.CurrentImage = bitmap;
I hope this helps someone who’s stuck with this annoying error!