What happens is, images are loaded on another thread. So, when my code asks for the image size, it's 0. Of course, this means if I am debugging, then I introduce a delay, so the thread can run, and the size is there. So, if you want to do anything when an image is loaded, your best bet, is to use the size changed event on the Image control. I've found that I need to put the images inside a StackPanel, if I put them in a Grid, they are just never visible, if I use the * notation, which I always try to do, to create forms that can be resized smoothly.
What the framework desperately needs, is an ImageLoaded event, so you can write code to run when the image loads, THEN tell it to start loading. I don't understand how this was missed, I'd have thought that being able to load an image, then do something based on the size of the image, would be pretty common in a framework whose main claim to fame is a freeform user interface.
No comments:
Post a Comment