How to change the Source of an Image in C#

I had a very hard time figuring out how to change an image source in a C# XAML app, so put my solution here.

First add this using directive:

using Windows.UI.Xaml.Media.Imaging;

Then add this line of code where you want to change the image source (Image being the image object):

Image.Source = new BitmapImage(new Uri(base.BaseUri, “/assets/your_image.png”));

If your image is not in the assets folder you need to replace base.BaseUri, “/assets/your_image.png” with the full image URI.

Hope this was helpful.


  1. great… just great
    thank you
    have a nice day

  2. Thank you so much

Leave a Reply

Your email address will not be published. Required fields are marked *