How to change image source in WP8 using C#

windows-phonewindows-phone-8

I have an Image object created in XAML in my Windows Phone 8 project. I'd like to change the Source property in C#. How would I go about doing that? I've followed the code at https://stackoverflow.com/questions/5770527/imagebutton-change-source-property but had no success. BitmapImage does not seem to be valid for Windows Phone 8. Does anyone know the correct way to change image sources in C# for WP8? Thank you.

Best Answer

Well the solution ended up being something simple. I just needed to import the System.Windows.Media.Imaging namespace. I added

using System.Windows.Media.Imaging;

to the top of my file, which fixed the problem.

Related Topic