tags:

views:

46

answers:

2

I have a converter that takes a string as input and returns an icon. It's used to provide a icon that is used in a list box. When the itemsSource is set to a list whose items have a property that returns a string, the XAML looks as follows:

<Image Source="{Binding FileName, Converter={StaticResource FileNameToIconConverter}}"/>

That is, the objects in the list have a property called FileName that is of type string.

However, I have another listbox whose itemsSource is a List. In this case, what property can be used to retrieve the string value of the List to send to the converter?

<Image Source="{Binding ??, Converter={StaticResource FileNameToIconConverter}}"/>

Thanks, Ted

+2  A: 

I'm not sure I follow your question, but it sounds as though you're binding to a list of strings and you want to bind directly to the string rather than a property on the string class itself? In that case, don't specify a path, or specify "." as the path:

<Image Source="{Binding Converter={StaticResource FileNameToIconConverter}}"/>

OR

<Image Source="{Binding ., Converter={StaticResource FileNameToIconConverter}}"/>

HTH, Kent

Kent Boogaart
Thanks Kent. Yes, your understanding of my question is correct. Specifying "." as the path did the trick.
A: 

Sounds like you want to bind to the selected item. check out this article, should help you

Muad'Dib