display image in silverlight 4
private void button1_Click(object sender, RoutedEventArgs e)
{
MyImage.Source = new BitmapImage(new Uri("../Image/" + txtImage.Text,
UriKind.Relative));
} 开发者_Go百科
Why is the image not showing?
Your relative URI cannot contain and especially start with "../"
.
Unless it starts with a "/"
, or an absolute URL starting with "http://"
, it is assumed to be in a module.
A URL like "/images/imagename.jpg"
will find the image located in the clientbin/images
folder on the hosting website.
Also take a look at my answer here for more info: Binding image in Isolated Storage
精彩评论