I have two ViewModel classes : PersonViewModel and PersonSearchListViewModel. One of the fields PersonViewModel implements is a profile image that is downloaded via WCF(cach
It can be achieved with WriteableBitmap.
public void LoadThumbAsync(Stream src,
WriteableBitmap bmp, object argument)
{
ThreadPool.QueueUserWorkItem(callback =>
{
bmp.LoadJpeg(src);
src.Dispose();
if (ImageLoaded != null)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
ImageLoaded(bmp, argument);
});
}
});
}
But You have to construct WriteableBitmap in UI Thread, then loading can be performed in other thread.
void DeferImageLoading( Stream imgStream )
{
// we have to give size
var bmp = new WriteableBitmap(80, 80);
imageThread.LoadThumbAsync(imgStream, bmp, this);
}
See more explanaition on this blog post