# .NET and More > Silverlight >  [RESOLVED] Silverlight Image

## peteshir

I have an image in a silverlight project. When I click a button I want the image to change to another image.

I saw that there is an imagesource property but I cannot simply put the Url of the new image in there.

Can someone help

Thanks 
Pete

----------


## MattP

Typed this straight in so apologies in advance for syntax errors.

Make sure you've imported System.Windows.Resources and System.Windows.Media.Imaging

If TheImage.png is located in Images folder and build action is set to Resource:



```
Dim sri As StreamResourceInfo = Application.GetResourceStream(New Uri("SilverlightApplication1;component/Images/TheImage.png", UriKind.Relative))
Dim bmp As New BitmapImage
bmp.SetSource(sri.Stream)

image1.Source = bmp
```

If TheImage.png is located in Images folder and build action is set to Content:



```
Dim sri As StreamResourceInfo = Application.GetResourceStream(New Uri("Images/TheImage.png", UriKind.Relative))
Dim bmp As New BitmapImage
bmp.SetSource(sri.Stream)

image1.Source = bmp
```

If TheImage.png is somewhere out on the web:



```
image1.Source = New BitmapImage(New Uri("http://domain.com/TheImage.png", UriKind.Absolute))
```

----------


## peteshir

Thanks. But I am having trouble with bmp.sersource.

BMP does not seem to have that method.

----------


## MattP

It's definitely available in Silverlight 3 when I try it.  BitmapImage should be in System.Windows.Media.Imaging.

----------


## peteshir

This is how I got it to work. 

        Image1.Source = New BitmapImage(New Uri("Photos/BrownBush.jpg", UriKind.RelativeOrAbsolute))

I had trouble with the code you sent Matt. I really don't know why. But this seemed to do the trick. Thanks for you help.

----------

