Silver Light question -- Load images from Local Computer

I am trying to dynamically load images into a silverlight project.  I made a Silverlight 3 project using VS 2010 Beta.  I want to load the images on to the canvas through code.  

the function that I have is:

   private void AddImage(double Left, double Top, int Height, int Width,int imageNum)
        {
            Image myImage = new Image();
            string uriString = "../images/img." + imageNum.ToString() + ".jpg";
            BitmapImage bmp = new BitmapImage();
            Uri uri1 = new Uri (uriString,UriKind.Relative );            
            bmp.UriSource = uri1;          
 
            myImage.Source = bmp;
            myImage.Width = Width;
            myImage.Height = Height;
            myImage.SetValue(Canvas.LeftProperty, Left);
            myImage.SetValue(Canvas.TopProperty, Top);
           
            myCanvas.Children.Add(myImage);
        }

the call is a simple loop of i from 1 to 3 that calls the AddImage as follows:
AddImage(i*115,100,100,100,i);

When I made silimar code to load rectangles onto the page it worked fine, with this image function it does not seem to work.  No error messages are generated, but nothing shows up on the canvas when I run this.  
VoodooFrogAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VoodooFrogAuthor Commented:
that is still not working:  here is the code as I changed it based on the code from that blog:

 private void AddImage(double Left, double Top, int Height, int Width,string path)
        {
            Image myImage = new Image();
            myImage.Source = new BitmapImage(new Uri(path, UriKind.Relative));
            myImage.Width = Width;
            myImage.Height = Height;
            myImage.SetValue(Canvas.LeftProperty, Left);
            myImage.SetValue(Canvas.TopProperty, Top);
            myCanvas.Children.Add(myImage);
}

called with
  while (i <= (Convert.ToInt16(a.Content.ToString())))
            {
                uriString = "/images/img." + i.ToString() + ".jpg";
               AddImage(((i) * 110) + 15, ((i) * 110) + 15, 100, 100,uriString);
}

in addition -- when I call    
 public MainPage()
        {            
            InitializeComponent();          
            AddImage(115,115,100,100,"/images/img1.jpg");        
        }

  it works fine apparently.  



0
VoodooFrogAuthor Commented:
I found a typo in my code...   a '.' after the img so the file string would  be created as img.1.jpg....   That is a frustrating mistake...  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.