No events are fired from an imagebrush via ImageOpened/ImageFailed
- by umlgorithm
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?