I have a WPF application which has a picture box with a graphic in it, I need a way to be able to change this graphic in a simple straightforward manner (like replacing an image file in the programs install directory).
Asked
Active
Viewed 759 times
2 Answers
2
I'm not sure if this is what you want, but...
You could do something like this:
Source="pack://siteoforigin:,,,/Images/someimage.png"
and use images off of your bin/app folder. Take a look at this link for more info...

Community
- 1
- 1

NSGaga-mostly-inactive
- 14,052
- 3
- 41
- 51
1
Define a function that loads an image from an external image file
public static ImageSource LoadImage(string fileName)
{
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri("file:///" + fileName.Replace("\\", "/"));
bitmap.EndInit();
return bitmap;
}
You can then assign an image controls source to this functions return value.
someImageControl.Source = LoadImage(@"d:\\images\\image.png");

Yiğit Yener
- 5,796
- 1
- 23
- 26