Question: 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.

Answer: 
Try setting the CacheOption for BitmapImage before freezing it. See if this works -

```
var image = new BitmapImage();
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad;
image.UriSource = urisource;
image.EndInit();
image.Freeze();

```
Before you freeze it, you need to fully render it.  

You should try to listen to the SourceUpdated event, and only then freeze the image.

On a side note, if you ever want to modify the Image after that, you will have to Clone it.