Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Setting image source through code?
6 replies. Latest Post by SteveWong on July 23, 2008.
(0)
Papasmur...
Member
3 points
8 Posts
07-23-2008 3:36 AM |
Hello,
I'm having my site create a products page dynamically--so we can add and delete products later and I won't have to recode those parts--and I've run into a slight problem with images: when I try to set the image source of my images, it says that I can't input the string address. So how do I do it?
Here is the code:
ProductImage(j) = New ImageProductImage(j).Source = "sitemedia/background.jpg"
rajesh s...
Contributor
2314 points
505 Posts
07-23-2008 3:44 AM |
use
image.SetSource( new URI(ImageSource));
SteveWong
6343 points
1,281 Posts
07-23-2008 3:48 AM |
For a image located at remote
MyImage.Source = new BitmapImage(new Uri("http://theURL/test.png"));
For a image located near you in your page location
MyImage.Source = new BitmapImage(new Uri("images/test.png", UriKind Relative));
07-23-2008 3:53 AM |
Hey Steve,
when I enter New BitmapImage it says there is no such thing (the only it gives is bitconverter). Do I need to import something first?
07-23-2008 3:55 AM |
Never mind, just figured it out :)
07-23-2008 4:00 AM |
Sorry i forgot that your are creating new image object...
image.SetSource( new BitMapImage(new URI(ImageSource)));
07-23-2008 4:22 AM |
Please Include the line at the top of C# code behind
using System.Windows.Media.Imaging;