views:

547

answers:

1

Didn't know how to phrase the question better but basically I have a usercontrol that I dynamically add into another usercontrol. The child usercontrol has a set of images and basically I need to know if they have fully loaded inside the parent usercontrol since I need their dimentions for a method (not just height and width).

Is there a type of event that can trigger when all the images in the child usercontrol have loaded in the parent?

To further explain my scenario, I need this since I am using farseer physics engine for silverlight and it aquires the shape of the image to use for collision detection, and since when I try to turn the images into a physics object it would not find the shape since the image is still being generated on screen and therefore throws an exception.

Update: This is what I have came up with so far

void currImg_ImageOpened(object sender, RoutedEventArgs e)
{

    var ImagesLoaded = true;
    for (int i = 0; i < ImageLoaded.Count-1; i++)
    {
        if (!ImageLoaded[i])
        {
            ImagesLoaded = false;
            ImageLoaded[i] = true;
            break;
        }
    }

    if (ImagesLoaded)
    {
        addPuppetPhysics(pg.currPuppet);
    }

}

Where ImageLoaded is a list of booleans, the method addPuppetPhysics applies the farseer physics to the usercontrol pg.currPuppet . Thing is the physics engine finds the first half of the images then doesn't find anymore (crashes on the same Image). If I merely load the usercontrol, then apply the physics with a button click, it works perfectly.

A: 

Can you detect when the images are finished loading in the child control? If so you may be able to create you own event -- ex: ImagesLoaded -- and handle that in the parent.

Matt Brunell
Well I am using silverlight 3 beta and there is ImageOpened event but seems to trigger before the usercontrol is fully loaded
Drahcir