ValueConverter is not called in DataTemplate binding

I have ComboBox

one that uses DataTemplate

. DataTemplate

contains a binding that is used IValueConverter

to convert the listed value to a string. The problem is that the value converter is never called. If I put a breakpoint at StatusToTextConverter.Convert()

, it never hits.

This is my XAML:

    <ComboBox ItemsSource="{Binding Path=StatusChoices, Mode=OneWay}">
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Converter={StaticResource StatusToTextConverter}}"/>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>

      

I thought this is how it implicitly binds to the value of a DataTemplate

. I'm wrong?

Edit: In context: I intend to display Image

in DataTemplate

next to the topic TextBox

. If I can't get the binding TextBox

to work, then I don't think it Image

will work either.

+2


a source to share


1 answer


In some cases, you must explicitly specify Path

for Binding

. Try this instead:



<TextBlock Text="{Binding Path=.,Converter={StaticResource StatusToTextConverter}}"/>

      

+3


a source







All Articles