I have a ComboBox
that uses a DataTemplate
. The DataTemplate
contains a binding which uses an IValueConverter
to convert an enumerated value into a string. The problem is that the value converter is never invoked. If I put a breakpoint in StatusToTextConverter.Convert()
, it never is hit.
This is my XAML:
<ComboBox ItemsSource="{Binding Path=Statu开发者_Go百科sChoices, Mode=OneWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource StatusToTextConverter}}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
I thought this is how one implicitly binds to the value a DataTemplate
is presenting. Am I wrong?
Edit: For context: I intend to display an Image
in the DataTemplate
alongside that TextBox
. If I can't get the TextBox
binding to work, then I don't think the Image
will work, either.
In some circumstances you must explicitly supply a Path
for a Binding
. Try this instead:
<TextBlock Text="{Binding Path=.,Converter={StaticResource StatusToTextConverter}}"/>
精彩评论