i got a situation... in my project, i need to show images from database on silver light pages...
so i developed like this...
in my XAML...
<Image Grid.Row="2" Margin="10" x:Name="image" Width="300" Height="200" HorizontalAlignment="Left"></Image>
and in my code
byte imageData = questions.ElementAt(Convert.ToInt16(x.Name)).Image;
var bitmapImage = new BitmapImage();
image.Source = bitmapImage;
but the image is not rendering.... can anyone help me
Hi.If i was you:
Save the name of my images in DataBase and Create a method like this:
public static BitmapImage GetBitMapImage(string relativeImage)
URI uri=new URI(imagePath,UriKind.RelativeOrAbsolute);
return new BitmapImage(uri);
"Images" in imagePath is a folder in your application that all of image is located in it.
when you need to an image.you must write:
Image myImage=new Image();
myImage.Source=GetBitMapImage(this place must populate with your image name that is saved in DataBase);
for example :
this acction is useful because when you need your image is loaded.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)