Tags: | Categories: Blog Posted by admin on 4/22/2009 3:27 PM | Comments (3)

This is a very simple code snip. This code below downloads an image, you expecting the events ImageFailed or Loaded to be called, none of them will be called. Is this a Silverlight bug?

Image image = new Image();                        
BitmapImage bi = new BitmapImage(new Uri(“http://weblogs.asp.net/blogs/albertpascual/Al%20Pascual%20tyniest.jpg”, UriKind.RelativeOrAbsolute));                        
image.ImageFailed += (object senderFailed, ExceptionRoutedEventArgs eFailed) =>
{
    // Handle the image failing 
    MessageBox.Show("Image Failed");
};
image.Loaded += (object senderLoaded, RoutedEventArgs eLoaded) =>
{
    // Delete this
    MessageBox.Show("Image Loaded");
};                        
image.Source = bi;

I reported this error on this thread, if any Silverlight knows the answer please contribute to the it.

Cheers

Al

Comments

on 4/22/2009 6:54 PM

Tweeted this to you, but thought I'd post it here too.


ImageFailed is only going to fire once the download tries, and that typically doesn't happen until you add the image to the tree. If you add the image to layoutroot or some other container, it will all work as expected.


Pete


on 4/22/2009 9:50 PM

Pingback from b a r s » Blog Archive » Silverlight Image event ImageFailed not being called : Al Pascual


on 4/23/2009 11:05 AM

Pingback from Silverlight Image event ImageFailed not being called | IT Questions


Comments are closed