Link to home
Start Free TrialLog in
Avatar of wint100
wint100Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Read number of Images in silverlight project

I'm using SL4 with a slideshow control to flick between image resources in the client app.

Currently my ViewModel has the code below, which loads the Images and the List is bound to the View. You can see in the code a Value of 6, which is the number of Images in the 'info1' folder. What I need to do is make this more dynamic, to allow more files to be added, without having to modify the code.

So, is there a way to count the number of resources in a project folder (info1 in this case)? I need this to be able to fire an event, when the view has been through all of the images, but that is really a seperate issue.

Would it be better to load the files from the Server, rather than from client resources? Or even load from a ZIP files, and count the number of files in the ZIP folder?

Any help appreciated.

Thanks
try
                {
                    for (int i = 0; i < 6; i++)
                    {
                        string fileNumber = (i + 1).ToString();
                        //if (i < 9)
                        //{
                        //    fileNumber = "0" + fileNumber;
                        //}
                        src = new Uri(@"/EnergyViewerV2;component/Images/infoImages/info1/officeEquip_Page_" + fileNumber + ".jpg", UriKind.RelativeOrAbsolute);
                        image = new BitmapImage(src);
                        imageList.Add(new Image() { Source = image });
                    }
                }
                catch (Exception ex)
                {

                    MessageBox.Show(ex.Message, "Data Display", MessageBoxButton.OKCancel);

                }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wint100

ASKER

The mthos I ended up using was to have a ZIP file on the Server, then the Silverlight Client would downlaod this using a webclient connection, unzip the contents, and count the number of files.

All seems to work well.