I want to bind an image source to a List item, but I need the binding to select an image from the list based on an argument – select the image from the List based on a boolean value within the list.
e.g.
Images List has a number of fields:
Images.Src
Images.IsMainImage (True/False)
etc.
I want my Binding to select the image from the List, based on IsMainImage = True.
Is it possible or can I only do this with a Converter?
I was hoping there would be some sort of way to use LINQ in the Binding or something like that.
All you can do is to use the converter or hide the items loaded into the ItemsControl using a trigger (it means they are present in the ItemsControl, but not visible) – it should not be a big deal if there aren’t too many of the items.
Maybe it would be possible to write a custom Binding class which would take a LINQ expression in string form, compile it ad use it to process the bound collection, but that would be colossal overkill. And would potentially lead to bad programming practices (coding more business logic into the XAML).