R – Silverlight Dynamic Image Loading Problem

asynchronousbindingimagesilverlightsilverlight-3.0

I am creating a FlippingBook Silverlight application and I have run into a snag that I cannot seem to solve.

The problem is with Asyncrously loaded Images. I have written a class that loads an image from a webaddress and stores it in a BitmapImage object.

I bind to this image object to the Image Source on the silverlight image control.
Now my Page and the Thumbnail both access the same ImageData Property that stores the images data.

The thumbnails list is a listbox that have been styled to serves as a thumbnail viewer.

Both the book and the listbox have same itemsource too, which is why the issues baffles me.

Everything is working with the images being loaded in the background and updating the UI when they have been loaded… EXCEPT the first 3 (and always the first 3) items in the thumbnail listbox never show the imagedata.

This is an image to illustrate the UI and problem:
alt text http://www.pcbuyersguide.co.za/picture.php?albumid=19&pictureid=895

Code Binding Image on Page:

    <Image Source="{Binding ImageData}" Stretch="Fill" ImageFailed="Image_ImageFailed"/>

Code Binding Image on Thumbnail(Styled ListboxItem):

    <Image Stretch="Fill" Source="{Binding ImageData}"/>

Property:

   public BitmapImage ImageData
    {
        get { return oImageData; }
        set
        {
            if (value != this.oImageData)
            {
                this.oImageData = value;
                NotifyPropertyChanged("ImageData");
            }
        }
    }

I have tested with images that take long to load and it is all working, but it's just these first 3 that are giving me hell. I don't understand as the items are bound and should effectively all be the same.

The ItemSource is an observablecollection. I know I haven't given a great deal of information but I want to try and focus my question. If you need more info I will be happy to provide it.

Any Help would be greatly appreciated.

Best Answer

It turned out to be a problem with a style on the ItemContentStyle that I had defined. I had the root Grid set to a certain fixed size which it appears silverlight doesn't like so I set the size on the image instead and did some other tweaks and it seemed to come right.