开发者

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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜