Q: WPF - Changing an image resource in a datatemplate programmatically I have a ListBox showing some objects associated each with some files. I also have a ListView of images linked to the listbox's selection. I would like the listview to show an icon corresponding to the filetype (an image for video, image, doc etc...) of each file with the filename below.
I can figure out all the code except how to bind the image source to the image control and access it programmatically.I'm unable to access any controls from the datatemplate in my code-behind.
Thx

A: Use a value converter which takes the file name with file type and return source of the image for that file type.

A: Excuse me for the late reply. I ended up solving the problem with a template selector and setting a different template for every filetype
