No events are fired from an imagebrush via ImageOpened/ImageFailed
Posted
by umlgorithm
on Stack Overflow
See other posts from Stack Overflow
or by umlgorithm
Published on 2010-04-09T01:43:59Z
Indexed on
2010/04/09
1:53 UTC
Read the original article
Hit count: 297
Silverlight
|image
A canvas is received from the server, and an image brush is extracted from the canvas via searching for a bunch of pathes. In summary, Canvas -> Path -> Path.Fill -> ImageBrush. Now, I want to take a snapshot of the ImageBrush using WriteableBitmap when it is loaded and here is what I did
var imageBrushes =
VisualTreeUtility.FindVisualChildren<Path>(canvas)
.Where(i => i.Fill.GetType() == typeof(ImageBrush))
.Select(p => p.Fill);
foreach(var image in imageBrushes)
{
image.ImageOpened += delegate { //never gets here };
image.ImageFailed += delegate { //never gets here either };
// if the image is already loaded
if (((BitmapSource)image.ImageSource).PixelWidth != 0)
{
// never gets here either
}
}
As you can see the comments in the code above, no matter what I try, I can't seem to catch an event from the image. Any suggestions?
© Stack Overflow or respective owner