Set the source for an image from C#

In Silverlight, there are two ways to set the source for an image.

  1. image.SetValue(Image.SourceProperty,value);
  2. image.Source = new BitmapImage(new Uri(value, UriKind.Absolute));

For the second option you will need to include the following namespace: using System.Windows.Media.Imaging;.

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: