Advertise with us

How to change image dynamically in wpf?

Posted by  Tanuj Kumar
WPF 
WPF
 4324  View(s)
Ratings:
Rate this:

myImage.Source = new BitmapImage(new Uri("/folder/imagename.png", UriKind.Relative));

This used to work in WPF applications for Windows 7, but there, in Windows 8, I got an error

Thanks in advance.

  1. Re: How to change image dynamically in wpf?

    Hi Tanuj,


    The Image.Source property is of type ImageSource. Therefore, try the following example:

    myImage.Source = "/YourApplicationName;component/folder/imagename.png";

Answer