This week end, I am so busy with my heavy work load… homework! But, I still want to share my experience on writeing Silverlight Application.
As I remembered, I have seen more than ten posts asking for the blinding of the source of their images.
Actually people want to make use of the images that they added to the project.
Honestly speaking, it has so many ways to do the trick.
Image Img = new Image(); BitmapImage bi3 = new BitmapImage(); bi3.UriSource = new Uri("pic.gif", UriKind.Relative); Img.Source = bi3;
Let me explain a little bit. If you added the image to your project, it is better for you to use UriKind.Relative. Just like the word “Relative” it is taking the resources relatively to the project. But how about somethings that are not added to the project?
Image Img = new Image(); BitmapImage bi3 = new BitmapImage(); bi3.UriSource = new Uri("http://localhost/pic.gif", UriKind.Absolute); Img.Source = bi3;
Apart from setting it programmatically with C#, you can also add it with xaml code throught C#.
Image img = XamlReader.Load(" " ) as Image; Layoutroot.children.add(img);
It is rare to see people using XamlReader, but it can really do the trick!
Live with Light
Steve Wong (Hong Kong)