I am using a viewmodel bound to an image property on the UI and the viewmodel contains an ImageSource property. I set that property using the following function
private BitmapImage GetImageFromUri(Uri urisource)
{
if (urisource == null)
return null;
var image = new BitmapImage();
image.BeginInit();
image.UriSource = urisource;
image.EndInit();
image.Freeze(); //commenting this shows the image if the routine is called from the proper thread.
return image;
}
For some odd reason, in the following code, when I call Freeze on my BitmapImage, it does not appear on the main window.I get no exception or crash. Can anybody help me with this? I am setting the image property asynchronously so I need to be able to use the created image, assuming the GetImageFromUri call was made from a thread other than the UI thread.