I came across this myself once and although it might not be the best solution, it worked for me.
1. Add images to your project, for example:
- Create images and icons in your project and add images there.
- Set image assembly action to Content (copy if new)
2. Create an ImageSource property:
public ImageSource YourImage { get { return _yourImage; } set { _yourImage = value; NotifyOfPropertyChange(() => YourImage); } }
(Note: I use a micron gauge to help in binding)
3. Update ImageSource as follows:
if(!string.IsNullOrEmpty("TheImageYouWantToShow")) { var yourImage = new BitmapImage(new Uri(String.Format("Images/Icons/{0}.jpg", TheImageYouWantToShow), UriKind.Relative)); yourImage.Freeze();
4. Associate the source attribute with the YourImage property:
(you already did it)
Deruijter
source share