We help IT Professionals succeed at work.
Get Started

Read number of Images in silverlight project

wint100 asked
Last Modified: 2012-06-27
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.

                    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

Watch Question
Chief Technology Ninja
Distinguished Expert 2020
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE