WPF - Correct Syntax for Using Coverter with Current Binding

Posted by Andy T on Stack Overflow See other posts from Stack Overflow or by Andy T
Published on 2010-04-16T12:01:54Z Indexed on 2010/04/16 12:03 UTC
Read the original article Hit count: 262

Filed under:
|
|
|
|

Hi,

I have a collection of hex strings that represent colours and I am binding a combobox's ItemsSource to that collection.

The combobox items are templated to have a filled rectangle with the relevant colour. I therefore need to use a converter to convert the hex value to a string. Easy enough.

However, Blend is telling me that this syntax is incorrect in my XAML:

Fill="{Binding, Converter={StaticResource StringToBrush}}"

Apparently, I can't use a converter against plain old 'Binding'. Blend says that something like this is syntactically correct:

Fill="{Binding Value, Converter={StaticResource StringToBrush}}" 

...However that obviously doesn't work.

I'm not quite au fait with binding syntax yet, so obviously I'm getting it wrong.

Can anyone advise the correct syntax to achieve what I'm trying to do (convert my bound String using the coverter StringToBrush)?

Thanks in advance!

AT

© Stack Overflow or respective owner

Related posts about wpf

Related posts about xaml