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;
the call is a simple loop of i from 1 to 3 that calls the AddImage as follows:
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.