I have a WPF App that implements a ListView. I would like to show an image (a small icon) in one of the columns depending on the type of the data that row represents. Sort of like the display you see in Windows Explorer.
I am using DataTriggers elsewhere in my XAML, it seems like a similar method could be used to swap out entire cell contents, but I can’t find an example of anyone doing that.
Any thoughts?
There are three common techniques for this.
1) DataTrigger:
2) ValueConverters:
3) MVVM (Model-View-ViewModel):
Create a ViewModel class that wraps your data model. This ViewModel would evaulate the properties in the data model and combine them with logic into a new property.
And the XAML: