Search Results

Search found 2 results on 1 pages for 'umlgorithm'.

Page 1/1 | 1 

  • 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?

    Read the article

  • Using ManualResetEvent to wait for multiple Image.ImageOpened events

    - by umlgorithm
    Dictionary<Image, ManualResetEvent> waitHandleMap = new Dictionary<Image, ManualResetEvent>(); List<Image> images = GetImagesWhichAreAlreadyInVisualTree(); foreach (var image in images) { image.Source = new BitmapImage(new Uri("some_valid_image_url")); waitHandleMap.Add(image, new ManualResetEvent(false)); image.ImageOpened += delegate { waitHandleMap[image].Set(); }; image.ImageFailed += delegate { waitHandleMap[image].Set(); }; } WaitHandle.WaitAll(waitHandleMap.Values.ToArray()); WaitHandle.WaitAll blocks the current UI thread, so ImageOpened/ImageFailed events would never get fired. Could you suggest me an easy workaround to wait for the multiple ui events?

    Read the article

1